Hello,
can anyone share some common scenario on how to initialise necessary things in web application using 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 methods 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
db.open(driver, conn);
databaseExists(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();
cmd.select(db.DEPARTMENTS.count());
db.querySingleInt(cmd.getSelect(), -1, conn);
###

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

Thanks for info,
David

Reply via email to