incubator-empire-db-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Marko <>
Subject How to use it with web application?
Date Thu, 25 Sep 2008 10:13:15 GMT
can anyone share some common scenario on how to initialise necessary things in web application
e.g. SpringFramework?

##### Using the code from the EmpireDB Site:
config.init((args.length > 0 ? args[0] : "config.xml"));
// STEP 1: Get a JDBC Connection
Connection conn = getJDBCConnection();
In step two the sample creates and initializes a database driver object for the target DBMS.
This is 
HSQLDB by default.

// STEP 2: Choose a driver
DBDatabaseDriver driver = getDatabaseDriver(config.getDatabaseProvider());
Then in step three the database object is opened using the driver. Only when opened, other
of the database object may be used. Finally we check whether or not our database objects exist.

// STEP 3: Open Database and check if tables exist, conn);
In order to check existence of the database the sample simply performs a query on the Departments

table ("select count(*) from DEPARTMENTS") using the following code:

DBCommand cmd = db.createCommand();;
db.querySingleInt(cmd.getSelect(), -1, conn);

... should/can be the conn and db initialised using some singleton pattern and used within
application in this way?

Thanks for info,

View raw message