Table of Contents
Since 5.1 version, DODS is independent from Enhydra. This means that it is possible for user to make any application (it doesn't need to be enhydra application) that can use DODS.
DODS works with DatabaseManagers. DatabaseManager is class that provides facilities for work with databases.
There are two modes of using DODS:
non-threading
In non-threading mode, only one DatabaseManager is used for the whole application, no matter the application has one or more Threads.
threading
In threading mode, there is one DatabaseManager for every Thread. User needs, for every Thread, to define DatabaseManager. If, for any Thread, the DatabaseManager is not defined, the default DatabaseManager is used.
In the following text, the DODS independence is explaned for non-threading mode.
To make non-enhydra application that can use DODS, the following things must be done:
You need to init DODS from your application source code. There are two ways to do this:
You can startup DODS with method
DODS.startup(String fileName)
to do this add code that makes new DatabaseManager and registers it in DODS.
Example:
try {
. . .
String fileName = "discRack.conf";
DODS.startup(fileName);
. . .
} catch (Exception e) {
e.printStackTrace();
}
In this case 'fileName' is absolute path to application's configuration file. If configuration file can not be found, on given path, then DODS try to find default 'dods/conf/databaseManager.conf' file in application's classpath (folders and jar-files).
Or you can startup DODS with method
DODS.startup(URL confURL, String confFile)
where:
- 'confURL parameter' is additional place (given as object of java.net.URL class) where DODS can search for application's configuration file, if confURL is set to 'null' then DODS use application's classpath to search for configuration file.
- 'confFile' is relative path to application's configuration file, relativ to 'confUrl' parameter (if they are not 'null' ),and to application's class path (folders and jar-files).
If DODS can not find 'fileName' file relativ to 'confURL' or application's class path, or 'fileName' parameter is set to null , then DODS try to open default configuration file 'dods/conf/databaseManager.conf' searching relatively to application classpath (folders and jar-files).
Example:
try {
. . .
String fileName = "discRack.conf";
DODS.startup(null, fileName); // or DODS.startup(someUrl, fileName);
. . .
} catch (Exception e) {
e.printStackTrace();
}
Where "discRack.conf" is an example of application's configuration file. This file is the same as the Database Manager section of Enhydra application's configuration file.
This file can look like this:
#-----------------------------------------------------------------------------
# Database Manager Configuration
#-----------------------------------------------------------------------------
#
# The databases that are used by CSAM. Each of these databases
# has configuration parameters set under DatabaseManager.DB."databaseName".
#
DatabaseManager.Databases[] = "sid1"
#
# The default database used in this application.
#
DatabaseManager.DefaultDatabase = "sid1"
#
# 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.sid1.ClassType = "Standard"
# DatabaseManager.DB.sid1.ClassType = "Oracle"
#
# The jdbc driver to use.
#
DatabaseManager.DB.sid1.JdbcDriver = "org.enhydra.instantdb.jdbc.idbDriver"
# DatabaseManager.DB.sid1.JdbcDriver = "oracle.jdbc.driver.OracleDriver"
# DatabaseManager.DB.sid1.JdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver"
#
# Database url.
#
DatabaseManager.DB.sid1.Connection.Url = "jdbc:idb:C:/DODS_6.0/output/examples/discrack/output/discRack.prp"
# DatabaseManager.DB.sid1.Connection.Url = "jdbc:oracle:thin:@MyHost:MyPort:MyDBName"
# DatabaseManager.DB.sid1.Connection.Url = "jdbc:odbc:discRack"
#
# Database user name. All connection are allocated by this user.
#
DatabaseManager.DB.sid1.Connection.User = "scott"
#DatabaseManager.DB.sid1.Connection.User = "Admin"
# Database user password.
#
DatabaseManager.DB.sid1.Connection.Password = "tiger"
#DatabaseManager.DB.sid1.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.sid1.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.sid1.Connection.AllocationTimeout = 10000
#
# Used to log database (SQL) activity.
#
DatabaseManager.DB.sid1.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. Parameter NextWithPrefix is implemented to solve problems with some databases which has NEXT as a reserver word (like Hsql). If this parametre set to true following statament will be used for update object id table: update OID_TABLE set OID_TABLE.next = ? where OID_TABLE.next = ?. Default value for this parameter is false.
# Parameter OidTableName represents name of table where oid numbers are stored. Default value for this parameter is objectid.
# Parameter NextColumnName represents name of column in objectid table where oid numbers are stored. Default value for this parameter is next.
#
DatabaseManager.DB.sid1.ObjectId.CacheSize = 20
DatabaseManager.DB.sid1.ObjectId.MinValue = 1000000
DatabaseManager.DB.sid1.ObjectId.NextWithPrefix = true
DatabaseManager.DB.sid1.ObjectId.OidTableName = objectid
DatabaseManager.DB.sid1.ObjectId.NextColumnName = next
#
# User wildcards
#
DatabaseManager.DB.User.userWildcard = "*"
DatabaseManager.DB.User.userSingleWildcard = "_"
DatabaseManager.DB.User.userSingleWildcardEscape = "$"
DatabaseManager.DB.User.userWildcardEscape = "$"
#
# Default table configuration
#
# DatabaseManager.defaults.AllReadOnly = false
DatabaseManager.defaults.lazyLoading = false
DatabaseManager.defaults.maxExecuteTime = 200
DatabaseManager.defaults.TransactionCaches = true
DatabaseManager.defaults.TransactionCheck = true
DatabaseManager.defaults.AutoSave = true
#
# Default database configuration
#
DatabaseManager.DB.sid1.TransactionCheck = false
DatabaseManager.DB.sid1.AutoSave = false
#
# Default cache configuration
#
DatabaseManager.defaults.cache.maxCacheSize = 500
DatabaseManager.defaults.cache.maxSimpleCacheSize = 100
DatabaseManager.defaults.cache.maxComplexCacheSize = 10
DatabaseManager.defaults.cache.maxMultiJoinCacheSize = 10
DatabaseManager.defaults.cache.reserveFactor = 0.1
#
# Table person - configuration
#
DatabaseManager.DB.sid1.person.lazyLoading = true
DatabaseManager.DB.sid1.person.cache.initialCondition = *
DatabaseManager.DB.sid1.person.cache.maxCacheSize = 800
DatabaseManager.DB.sid1.person.cache.reserveFactor = 0.25
#
# Table Disc - configuration
#
DatabaseManager.DB.sid1.Disc.maxExecuteTime = 500
DatabaseManager.DB.sid1.Disc.cache.maxSimpleCacheSize = 300
DatabaseManager.DB.sid1.Disc.cache.maxComplexCacheSize = 150
DatabaseManager.DB.sid1.Disc.cache.maxMultiJoinCacheSize = 100
The example of non-enhydra application that can use DODS is DiscRack application, explained in next section.
Examples of DODS non-enhydra applications are included in DODS installation and they are in DODS, in directory:
<DODS_HOME>/examples
Process of running non-enhydra application will be presented in this section on the example Disc Rack. This example application is in <DODS_HOME>/examples/discrack directory.
To run example , these steps have to be done in Command Promt:
first, go to wanted example (directory)
cd <DODS_HOME>/examples/discrack
second, run ant, by typing:
ant
ant will build this application in its <output_directory>
then, go to application's output directory:
cd <output_directory>
then, example will be run with:
run
The ant, which is used here, must be DODS's ant.bat, which means that path <DODS_HOME>/bin must be included at the beginning of the system path.