in nmr/audit/src/main/java/org/apache/servicemix/nmr/audit/jdbc/JdbcAuditor.java [74:110]
public JDBCAdapter createAdapter() throws AuditorException {
JDBCAdapter jdbcAdapter;
if (this.dataSource == null) {
throw new IllegalArgumentException("dataSource should not be null");
}
if (statements == null) {
statements = new Statements();
statements.setStoreTableName(tableName);
}
Connection connection = null;
boolean restoreAutoCommit = false;
try {
connection = getDataSource().getConnection();
if (connection.getAutoCommit()) {
connection.setAutoCommit(false);
restoreAutoCommit = true;
}
jdbcAdapter = JDBCAdapterFactory.getAdapter(connection);
if (statements == null) {
statements = new Statements();
statements.setStoreTableName(tableName);
}
jdbcAdapter.setStatements(statements);
if (createDataBase) {
jdbcAdapter.doCreateTables(connection);
}
connection.commit();
} catch (SQLException e) {
throw (AuditorException) new AuditorException("Exception while creating database").initCause(e);
} catch (IOException e) {
throw (AuditorException) new AuditorException("Exception while creating database").initCause(e);
} finally {
close(connection, restoreAutoCommit);
}
this.tccl = Thread.currentThread().getContextClassLoader();
return jdbcAdapter;
}