use of org.olat.core.logging.StartupException in project openolat by klemens.
the class InnoDBAwareDriverManagerDataSource method init.
@Override
public void init() {
// test makes only sense if mysql with innoDb tables are used
if (!dbVendor.contains("mysql")) {
return;
}
Statement statement = null;
try {
log.audit("Checking whether mysql tables support transactions based on innoDB tab...");
statement = this.getConnection().createStatement();
statement.execute("show create table o_plock;");
ResultSet result = statement.getResultSet();
result.first();
String createTableCommand = result.getString("Create Table");
if (createTableCommand.contains("InnoDB")) {
log.audit("Your mysql tables look like they support transactions, fine!");
} else {
throw new StartupException("Your tables do not support transactions based on innoDB tables. Check your database server and enable innoDB engine! Your table currently runs: " + createTableCommand);
}
} catch (SQLException e) {
if (e.getMessage().contains("doesn't exist")) {
log.audit("o_plock table does not yet exist, will check transaction support on next startup");
} else {
throw new StartupException("Could not execute db statement.", e);
}
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (SQLException e2) {
log.warn("Could not close sql statement", e2);
throw new StartupException("Could not close sql statements.", e2);
}
}
}
Aggregations