Connecting to the database

The JDBCJournalSchemaGenerator class uses its own connection to the database. Once you have created an instance of the class, run the connect method the database URL where the journal tables are to be created as an argument. Note that the schema generator must be in the same JVM as the JDBC driver.

The following is an example of requesting a connection to the database:

JDBCJournalSchemaGenerator jsg=new JDBCJournalSchemaGenerator();
Properties env = new Properties();
env.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, 
    "com.ibm.websphere.naming.WsnInitialContextFactory");
javax.naming.Context ctx = new InitialContext(env);
DataSource ds = (DataSource)ctx.lookup("jdbc/ej");
jsg.databaseConnection = ds.getConnection(dbUserID, dbPassword);

This method sets the databaseConnection static attribute of the Schema Generator. The Schema Generator does not use the connection pooling facilities.