in main/src/main/java/org/apache/servicemix/kernel/main/Statements.java [56:100]
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) {
System.err.println(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) {
System.err.println("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) {
System.err.println(ignore);
} finally {
try {
s.close();
} catch (Throwable e) {
// ignore
}
}
}