in plugins/org.apache.karaf.eik.app/src/main/java/org/apache/karaf/main/Statements.java [112:156]
public void init (Connection lockConnection) {
Statement s = null;
try {
// Check to see if the table already exists. If it does, then don't
// log warnings during startup.
// Need to run the scripts anyways since they may contain ALTER
// statements that upgrade a previous version
// of the table
boolean alreadyExists = false;
ResultSet rs = null;
try {
rs = lockConnection.getMetaData().getTables(null, null, lockTableName, new String[] {"TABLE"});
alreadyExists = rs.next();
} catch (Throwable ignore) {
LOG.severe("Error testing for db table: " + ignore);
} finally {
close(rs);
}
if (alreadyExists) {
return;
}
s = lockConnection.createStatement();
String[] createStatments = {lockCreateStatement, lockPopulateStatement};
for (int i = 0; i < createStatments.length; i++) {
// This will fail usually since the tables will be
// created already.
try {
s.execute(createStatments[i]);
} catch (SQLException e) {
LOG.severe("Could not create JDBC tables; they could already exist."
+ " Failure was: " + createStatments[i] + " Message: " + e.getMessage()
+ " SQLState: " + e.getSQLState() + " Vendor code: " + e.getErrorCode());
}
}
lockConnection.commit();
} catch (Exception ignore) {
LOG.severe("Error occured during initialization: " + ignore);
} finally {
try {
if (s != null) { s.close(); }
} catch (Throwable e) {
LOG.severe("Error occured while closing connection: " + e);
}
}
}