// This embedded SQL database contains metadata about the reports
System.setProperty("derby.system.home", dataDirName);
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
} catch (InstantiationException e) {
throw new XTraceException(
"Unable to instantiate internal database", e);
} catch (IllegalAccessException e) {
throw new XTraceException(
"Unable to access internal database class", e);
} catch (ClassNotFoundException e) {
throw new XTraceException(
"Unable to locate internal database class", e);
}
try {
try {
// Connect to existing DB
conn = DriverManager.getConnection("jdbc:derby:tasks");
} catch (SQLException e) {
// DB does not exist - create it
conn = DriverManager
.getConnection("jdbc:derby:tasks;create=true");
createTables();
conn.commit();
}
conn.setAutoCommit(false);
} catch (SQLException e) {
throw new XTraceException("Unable to connect to interal database: "
+ e.getSQLState(), e);
}
LOG.info("Successfully connected to the internal Derby database");
try {
createPreparedStatements();
} catch (SQLException e) {
throw new XTraceException("Unable to setup prepared statements", e);
}
databaseInitialized = true;
}