Author's Email: GW.Estep@riva.com
Authors Website: http://www.riva.com
My simple requirements were as follows:
cd /usr/prjRun the Enhydra newapp command to create the project tree.
newapp simpledbBuild your new Enhydra application
cd /usr/prj/simpledb makeRun your new Enhydra application
cd /usr/prj/simpledb/output ./startTest your new Enhydra application
http://localhost:9000/Welcome.poKill the Enhydra server
Ctl-C
cd /usr/prj/simpledb/simpledb/presentationedit the Welcome.html file
<P><SPAN ID="name">This is the text that will be replaced when this application is completely working.</SPAN>Save the file
Build your new Enhydra application again
cd /usr/prj/simpledb makeRun your new Enhydra application again
cd /usr/prj/simpledb/output ./startTest your new Enhydra application again
http://localhost:9000/Welcome.poYou should see the line you typed in the HMTL file at the bottom of the page.
Kill the Enhydra server
Ctl-C
Run Access Select "Blank Database" option <OK> Save the file as /usr/prj/simpledb/simpledb.mdb Create two tables as follows:
table#1: name = objectid table#1:field#1: name = next, DataType = Number, designate as primary key
Add a record to the objectid table with the next field = 1
table#2: name = person table#2:field#1: name = OId, DataType = Number, designate as primary key table#2:field#2: name = version, DataType = Number table#2:field#3: name = name, DataType = Text
Add a record to the person table with the name field = "simpledb works!",
oid=1, and vesion=1. Add one record to the OId table with next=2.
Quit Access
Start->Settings/Control Panel->ODBC Data Sources Select "User DSN" tab <Add...> Select "Microsoft Access Driver" <Finish> Data Source Name field = "simpledb" without the quotes. <Select...> Browse to the simpledb.mdb file you just create above and select it. <OK> <OK>
DODS doesn't work right if the data directory already exists
rm -rf /usr/prj/simpledb/simpledb/data
Run DODS
dods <enter>
Setup the packages correctly
Select the <root> package node in the lower left window. Edit->Package change name to "simpledb" no quotes <OK>
Select the <simpledb> package node in the lower left window Insert->Package Change New Name field to "data" no quotes <OK>
Select the <data> package node in the lower left window Insert->Data Object Change Name field to "Person" no quotes Select Database Tab Change db Table Name field to "person" no quotes <OK>
Select <Person> Data Object Node in lower left window Insert->Attribute Change name field to "name" no quotes
Select Database tab and check "Can be queried" <OK>
File->Save As browse to /usr/prj/simpledb and change the File name field to simpledb.doml <Save>
File->Build All browse to /usr/prj/simpledb/simpledb and change the File name field to "data" no quotes <Re/Create Directory> You'll see a window pop up that shows the build progress of the DODS output. <Close> when the last message is "DODS BUILD COMPLETE"
Quit DODS
/usr/prj/simpledb/simpledb/presentation/Welcome.java
file.
Add access to the DODS generated Data Object package by inserting the
following code in red into the file Welcome.java
.
package simpledb.presentation; import java.util.Date; import com.lutris.xml.xmlc.*; import com.lutris.appserver.server.httpPresentation.*; import simpledb.data.*; import com.lutris.dods.builder.generator.query.*; public class Welcome implements HttpPresentation { public void run(HttpPresentationComms comms) throws HttpPresentationException, NonUniqueQueryException, DataObjectException { String now = new Date().toString(); WelcomeHTML welcome = (WelcomeHTML)comms.xmlcFactory.create(WelcomeHTML.class); welcome.setTextTime(now); PersonDO person; PersonQuery pquery = new PersonQuery(); person = pquery.getNextDO(); welcome.setTextName( person.getName() ); comms.response.writeHTML(welcome); } }
Save the file
#----------------------------------------------------------------------------- # Database Manager Configuration #----------------------------------------------------------------------------- # # The databases that are used by CSAM. Each of these databases # has configuration parameters set under DatabaseManager.DB."databaseName". # DatabaseManager.Databases[] = "simpledb" # # The default database used in this application. # DatabaseManager.DefaultDatabase = "simpledb" # # Turn on/off debugging for transactions or queries. Valid values # are "true" or "false". # DatabaseManager.Debug = "false" # # The type of database. Normally this is "Standard". # DatabaseManager.DB.simpledb.ClassType = "Standard" # # The jdbc driver to use. # DatabaseManager.DB.simpledb.JdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver" # # Database url. # DatabaseManager.DB.simpledb.Connection.Url = "jdbc:odbc:simpledb" # # Database user name. All connection are allocated by this user. # DatabaseManager.DB.simpledb.Connection.User = "Admin" # # Database user password. Microsoft Access default is "Admin". # The default password is blank. DatabaseManager.DB.simpledb.Connection.Password = "" # # The maximum number of connections that a connection # pool will hold. If set to zero, then connections # are allocated indefinitly or until the database # refuses to allocate any new connections. # DatabaseManager.DB.simpledb.Connection.MaxPoolSize = 30 # # Maximum amount of time that a thread will wait for # a connection from the connection pool before an # exception is thrown. This will prevent possible dead # locks. The time out is in milliseconds. If the # time out is zero, the allocation of connections # will wait indefinitely. # DatabaseManager.DB.simpledb.Connection.AllocationTimeout = 10000 # # Used to log database (SQL) activity. # DatabaseManager.DB.simpledb.Connection.Logging = false # # The number of object identifiers that are allocated # as a group and held in memory. These identifiers # are assigned to new data objects that are inserted # into the database. # DatabaseManager.DB.simpledb.ObjectId.CacheSize = 20 DatabaseManager.DB.simpledb.ObjectId.MinValue = 1
cd /usr/prj/simpledb makeRun the application
cd output ./startTest the application
http://localhost:9000/Welcome.poYou should see the original text that mentioned it would be replaced when
If you did all of the above right, you now have a simple Enhydra application on your hands that works with a database and DODS output which is integrated in a newapp generated application. Congrats!!!
G.W.
Last edited: Peter Darrah, peter@lutris.com, March 23, 2000