Search in sources :

Example 26 with StartupException

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);
        }
    }
}
Also used : StartupException(org.olat.core.logging.StartupException) SQLException(java.sql.SQLException) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet)

Aggregations

StartupException (org.olat.core.logging.StartupException)26 File (java.io.File)10 IOException (java.io.IOException)6 SQLException (java.sql.SQLException)6 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Resource (org.springframework.core.io.Resource)6 InputStream (java.io.InputStream)4 Statement (java.sql.Statement)4 XStream (com.thoughtworks.xstream.XStream)2 BufferedReader (java.io.BufferedReader)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStreamReader (java.io.InputStreamReader)2 ResultSet (java.sql.ResultSet)2 Properties (java.util.Properties)2 StringTokenizer (java.util.StringTokenizer)2 FastHashMap (org.apache.commons.collections.FastHashMap)2 CoreSpringFactory (org.olat.core.CoreSpringFactory)2 AssertException (org.olat.core.logging.AssertException)2 AuthenticationProvider (org.olat.login.auth.AuthenticationProvider)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2