* on I/O error
*/
@Override
protected void initDatabase() throws NamingException, RepositoryException, IOException
{
DBInitializer dbInitializer = null;
if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
{
LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
dbInitializer =
new OracleDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_ORACLE)
{
this.connFactory = new DefaultOracleConnectionFactory(getDataSource(), containerConfig);
dbInitializer = new OracleDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_PGSQL)
{
this.connFactory = new PostgreConnectionFactory(getDataSource(), containerConfig);
dbInitializer =
new PgSQLDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_PGSQL_SCS)
{
this.connFactory = new PostgreSCSConnectionFactory(getDataSource(), containerConfig);
dbInitializer = new PgSQLDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL
|| containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8
|| containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM
|| containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
{
if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM
|| containerConfig.dbDialect == DBConstants.DB_DIALECT_MYSQL_MYISAM_UTF8)
{
LOG.warn("MyISAM is not supported due to its lack of transaction support and integrity check, so use it only"
+ " if you don't expect any support and performances in read accesses are more important than the consistency"
+ " in your use-case. This dialect is only dedicated to the community.");
}
this.connFactory = new MySQLConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_MSSQL)
{
this.connFactory = new MSSQLConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DERBY)
{
this.connFactory = defaultConnectionFactory();
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2)
{
this.connFactory = new DB2ConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_DB2V8)
{
new DB2ConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_SYBASE)
{
this.connFactory = new SybaseConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_INGRES)
{
this.connFactory = defaultConnectionFactory();
// using Postgres initializer
dbInitializer =
new IngresSQLDBInitializer(this.connFactory.getJdbcConnection(), containerConfig);
}
else if (containerConfig.dbDialect == DBConstants.DB_DIALECT_HSQLDB)
{
this.connFactory = new HSQLDBConnectionFactory(getDataSource(), containerConfig);
dbInitializer = defaultDBInitializer();
}
else
{
// generic, DB_HSQLDB
this.connFactory = defaultConnectionFactory();
dbInitializer = defaultDBInitializer();
}
// database type
try
{
dbInitializer.init();
}
catch (DBInitializerException e)
{
LOG.error("Error of init db " + e, e);
}