Search in sources :

Example 36 with DataAccessResourceFailureException

use of org.springframework.dao.DataAccessResourceFailureException in project uPortal by Jasig.

the class DatabaseMetaDataImpl method runDatabaseTests.

/**
 * Run a set of tests on the database to provide better meta data.
 */
private void runDatabaseTests() {
    Connection conn = null;
    try {
        conn = this.dataSource.getConnection();
        // The order of these tests is IMPORTANT, each may depend on the
        // results of the previous tests.
        this.getMetaData(conn);
        final JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);
        this.testDatabaseInitialized(jdbcTemplate);
        if (this.portalTablesExist) {
            this.testOuterJoins(jdbcTemplate);
            this.testTimeStamp(jdbcTemplate);
        }
    } catch (SQLException e) {
        LOG.error("Error during database initialization. ", e);
        /*
             * We must throw a RuntimeException here to avoid starting the portal
             * with incorrect assumptions about what the database supports.
             */
        throw new DataAccessResourceFailureException("Error during database initialization. ", e);
    } finally {
        this.releaseConnection(conn);
    }
}
Also used : SQLException(java.sql.SQLException) DataAccessResourceFailureException(org.springframework.dao.DataAccessResourceFailureException) Connection(java.sql.Connection) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate)

Aggregations

DataAccessResourceFailureException (org.springframework.dao.DataAccessResourceFailureException)36 SQLException (java.sql.SQLException)10 Connection (java.sql.Connection)6 IOException (java.io.IOException)5 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 File (java.io.File)3 ResultSet (java.sql.ResultSet)3 Statement (java.sql.Statement)3 Test (org.junit.Test)3 EventProxyException (org.opennms.netmgt.events.api.EventProxyException)3 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)3 FileOutputStream (java.io.FileOutputStream)2 Clob (java.sql.Clob)2 DatabaseMetaData (java.sql.DatabaseMetaData)2 Date (java.util.Date)2 EntityManager (javax.persistence.EntityManager)2 PersistenceException (javax.persistence.PersistenceException)2 PrefabGraph (org.opennms.netmgt.model.PrefabGraph)2 DatabaseMetaDataCallback (org.springframework.jdbc.support.DatabaseMetaDataCallback)2