persistenceHandler = new RDBMSPersistenceHandler(this);
// Retrieve the Database Adapter for this datastore
try
{
ManagedConnection mc = getConnection();
Connection conn = (Connection)mc.getConnection();
if (conn == null)
{
//somehow we haven't got an exception from the JDBC driver
//to troubleshoot the user should telnet to ip/port of database and check if he can open a connection
//this may be due to security / firewall things.
throw new JPOXDataStoreException(LOCALISER_RDBMS.msg("050007"));
}
try
{
dba = RDBMSAdapterFactory.getInstance().getDatastoreAdapter(clr, conn,
conf.getStringProperty("org.jpox.datastoreAdapterClassName"),
omfContext.getPluginManager());
dba.loadDatastoreMapping(omfContext.getPluginManager(), clr);
// Check if the user has specified DefaultCatalogName/DefaultSchemaName and whether the DBA allows it
if (conf.hasProperty("org.jpox.mapping.Catalog") && !((RDBMSAdapter)dba).supportsCatalogsInTableDefinitions())
{
JPOXLogger.DATASTORE.warn(LOCALISER_RDBMS.msg("050002",
conf.getStringProperty("org.jpox.mapping.Catalog")));
}
if (conf.hasProperty("org.jpox.mapping.Schema") && !((RDBMSAdapter)dba).supportsSchemasInTableDefinitions())
{
JPOXLogger.DATASTORE.warn(LOCALISER_RDBMS.msg("050003",
conf.getStringProperty("org.jpox.mapping.Schema")));
}
// Create an identifier factory - needs the database adapter to exist first
initialiseIdentifierFactory(omfContext);
// Create the SQL controller
sqlController = new SQLController(((RDBMSAdapter)dba).supportsStatementBatching(),
conf.getIntProperty("org.jpox.rdbms.statementBatchLimit"),
conf.getIntProperty("org.jpox.query.timeout"));
if (autoStartMechanism == null)
{
// No auto-start specified so use RDBMS default of SchemaTable
// TODO When CORE-3328 is fixed change this to "SchemaTable2"
autoStartMechanism = "SchemaTable";
}
// Initialise the Schema "Name", and "Data"
initialiseSchema(autoStartMechanism, conf.getStringProperty("org.jpox.autoStartMechanismMode"),
conn, clr);
}
finally
{
mc.close();
}
}
catch (JPOXException jpex)
{
JPOXLogger.DATASTORE_SCHEMA.error(LOCALISER_RDBMS.msg("050004"), jpex);