ejb3/src/main/java/org/jboss/as/ejb3/timerservice/persistence/database/DatabaseTimerPersistence.java
private void checkDatabase() {
        String loadTimer = sql(LOAD_TIMER);
        Connection connection = null;
        Statement statement = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
            //test for the existence of the table by running the load timer query
            connection = dataSource.getConnection();
            if (connection.getTransactionIsolation() < Connection.TRANSACTION_READ_COMMITTED) {
                EjbLogger.EJB3_TIMER_LOGGER.wrongTransactionIsolationConfiguredForTimer();
            }
            preparedStatement = connection.prepareStatement(loadTimer);
            preparedStatement.setString(1, "NON-EXISTENT");
            preparedStatement.setString(2, "NON-EXISTENT");
            preparedStatement.setString(3, "NON-EXISTENT");
            resultSet = preparedStatement.executeQuery();
        } catch (SQLException e) {
            //the query failed, assume it is because the table does not exist
            if (connection != null) {
                try {
                    String createTable = sql(CREATE_TABLE);
                    String[] statements = createTable.split(";");
                    for (final String sql : statements) {
                        try {
                            statement = connection.createStatement();
                            statement.executeUpdate(sql);
                        } finally {
                            safeClose(statement);
                        }
                    }
                } catch (SQLException e1) {
                    EjbLogger.EJB3_TIMER_LOGGER.couldNotCreateTable(e1);
                }
            } else {
                EjbLogger.EJB3_TIMER_LOGGER.couldNotCreateTable(e);
            }
        } finally {
            safeClose(resultSet);
            safeClose(preparedStatement);
            safeClose(statement);
            safeClose(connection);
        }
    }
private void checkDatabase() {
        String loadTimer = sql(LOAD_TIMER);
        Connection connection = null;
        Statement statement = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
            //test for the existence of the table by running the load timer query
            connection = dataSource.getConnection();
            if (connection.getTransactionIsolation() < Connection.TRANSACTION_READ_COMMITTED) {
                EjbLogger.EJB3_TIMER_LOGGER.wrongTransactionIsolationConfiguredForTimer();
            }
            preparedStatement = connection.prepareStatement(loadTimer);
            preparedStatement.setString(1, "NON-EXISTENT");
            preparedStatement.setString(2, "NON-EXISTENT");
            preparedStatement.setString(3, "NON-EXISTENT");
            resultSet = preparedStatement.executeQuery();
        } catch (SQLException e) {
            //the query failed, assume it is because the table does not exist
            if (connection != null) {
                try {
                    String createTable = sql(CREATE_TABLE);
                    String[] statements = createTable.split(";");
                    for (final String sql : statements) {
                        try {
                            statement = connection.createStatement();
                            statement.executeUpdate(sql);
                        } finally {
                            safeClose(statement);
                        }
                    }
                } catch (SQLException e1) {
                    EjbLogger.EJB3_TIMER_LOGGER.couldNotCreateTable(e1);
                }
            } else {
                EjbLogger.EJB3_TIMER_LOGGER.couldNotCreateTable(e);
            }
        } finally {
            safeClose(resultSet);
            safeClose(preparedStatement);
            safeClose(statement);
            safeClose(connection);
        }
    }
private void checkDatabase ( ) { String loadTimer = sql ( LOAD_TIMER ) ; Connection connection = null ; Statement statement = null ; PreparedStatement preparedStatement = null ; ResultSet resultSet = null ; try { //test for the existence of the table by running the load timer query connection = dataSource . getConnection ( ) ; if ( connection . getTransactionIsolation ( ) < Connection . TRANSACTION_READ_COMMITTED ) { EjbLogger . EJB3_TIMER_LOGGER . wrongTransactionIsolationConfiguredForTimer ( ) ; } preparedStatement = connection . prepareStatement ( loadTimer ) ; preparedStatement . setString ( 1 , "NON-EXISTENT" ) ; preparedStatement . setString ( 2 , "NON-EXISTENT" ) ; preparedStatement . setString ( 3 , "NON-EXISTENT" ) ; resultSet = preparedStatement . executeQuery ( ) ; } catch ( SQLException e ) { //the query failed, assume it is because the table does not exist if ( connection != null ) { try { String createTable = sql ( CREATE_TABLE ) ; String [ ] statements = createTable . split ( ";" ) ; for ( final String sql : statements ) { try { statement = connection . createStatement ( ) ; statement . executeUpdate ( sql ) ; } finally { safeClose ( statement ) ; } } } catch ( SQLException e1 ) { EjbLogger . EJB3_TIMER_LOGGER . couldNotCreateTable ( e1 ) ; } } else { EjbLogger . EJB3_TIMER_LOGGER . couldNotCreateTable ( e ) ; } } finally { safeClose ( resultSet ) ; safeClose ( preparedStatement ) ; safeClose ( statement ) ; safeClose ( connection ) ; } }
Checks whether the database transaction configuration is appropriate
and create the timer table if necessary.
Checks whether the database transaction configuration is appropriate and create the timer table if necessary .