Wednesday 23 July 2008

ArtenSUITE: Part 2: Day One

ArtenSUITE
A Development Journal
Part 2: Day One


So yesterday I made a start on the ArtenBASE application which will be the central ‘hub’ for the ArtenSUITE applications. Within my REALbasic project I’ve organised it into folders as such:

        Codebase (core modules and classes, db access, autoupdate etc.)
        Pictures (images)
        Forms (windows)
        Modules (application specific modules and classes)
        Menus (application menu objects)

I have a standard module called mProgramInfo that contains properties that relate to the application: build, version, author etc. I modify these and import my standard ‘About’ window which uses these values. My about window for ArtenBASE looks like this:



I’ve created the methods needed to logon to Oracle and these are called automatically when the program is opened. I am using the Java Plugin from MBS to access the Oracle database. The logon method for Oracle is shown below:

'Requires the Oracle Java Driver Resident in the Program Directory
'(ojdbc14.jar)
'Requires the MBS REALbasic Java Plugin.rbx to be in the Plugins Directory of the IDE
'Requires the MBS REALbasic Main Plugin.rbx to be in the Plugins Directory of the IDE

'This Function Should be Called as Follows:
'mCodeBaseDB.OpenOracleDatabase("jdbc:oracle:thin:@//HostIPAddress:PortNumber/ORACLESID","username","password",ShowMessageInteger)

dim db as JavaDatabaseMBS
dim f as FolderItem

proDBConnector = "ojdbc14.jar"

f=GetFolderItem(proDBConnector)
if not f.Exists then
mCodebaseStd.DisplayStopMessage("Connector File Not Found in Application Directory ..."+EndOfLine+"Connector Name: "+proDBConnector)
Return
end if

db=new JavaDatabaseMBS(f,"oracle.jdbc.driver.OracleDriver")
db.Host=strHostName
db.UserName = strUserName
db.Password = strPassWord

if db.Connect then
mProgramInfo.pDBConnectStatus = True
db.AutoCommit = FALSE
if intShowMessage=1 then
mCodebaseStd.DisplayInformationMessage("Successfully Connected to Oracle ...")
end if
else
mProgramInfo.pDBConnectStatus = False
mCodebaseStd.DisplayStopMessage("Could Not Connect to Oracle ..."+EndOfLine+"Error Message: "+db.ErrorString+EndOfLine+"Error Code: "+str(db.Errorcode))
Return
end if



The first time the program is opened these methods will fail as the server logon details are undefined. With Oracle all database objects are owned by a user, in this case the user will always be ARTEN and the password will be encrypted and hard coded into the application. The Host IP and the Database Name are all that is specific to a particular environment. To define these details the preferences window is used:



Assuming the database connection was successfull the user will see the logon window. This is where they logon to the application database using a name and password stored in a (not yet created) table on the Oracle server. The logon window is shown below:



All screenshots are shown from the Mac OSX version as I am having a problem with the Java classes on Windows .... It’s one of those stupid problems I am sure and I will be glad to finally get to the bottom of it !

Anyway - that’s all folks for Day one of my new development. Today I’m going to spend some time trying to solve this Windows/Java problem and also take care of creating some of those database tables :-)

"You can't ever be really free if you admire somebody too much." - Tove Jansson

No comments: