@Override public SqlStatement[] generateStatements(Database database) throws CustomChangeException { this.database = database; jdbcConnection = (JdbcConnection) database.getConnection(); connection = jdbcConnection.getWrappedConnection(); if (isApplicable()) { confirmationMessage.append(getTaskId() + ": "); generateStatementsImpl(); } else { confirmationMessage.append(getTaskId() + ": no update applicable for this task"); } return statements.toArray(new SqlStatement[statements.size()]); }
protected boolean isApplicable() throws CustomChangeException { try { String correctedTableName = database.correctObjectName("REALM", Table.class); if (SnapshotGeneratorFactory.getInstance().has(new Table().setName(correctedTableName), database)) { ResultSet resultSet = connection.createStatement().executeQuery("SELECT ID FROM " + getTableName(correctedTableName)); try { return (resultSet.next()); } finally { resultSet.close(); } } else { return false; } } catch (Exception e) { throw new CustomChangeException("Failed to check database availability", e); } }
protected boolean isApplicable() throws CustomChangeException { try { String correctedTableName = database.correctObjectName("REALM", Table.class); if (SnapshotGeneratorFactory.getInstance().has(new Table().setName(correctedTableName), database)) { ResultSet resultSet = connection.createStatement().executeQuery("SELECT ID FROM " + getTableName(correctedTableName)); try { return (resultSet.next()); } finally { resultSet.close(); } } else { return false; } } catch (Exception e) { throw new CustomChangeException("Failed to check database availability", e); } }
@Override public SqlStatement[] generateStatements(Database database) throws CustomChangeException { this.database = database; jdbcConnection = (JdbcConnection) database.getConnection(); connection = jdbcConnection.getWrappedConnection(); if (isApplicable()) { confirmationMessage.append(getTaskId() + ": "); generateStatementsImpl(); } else { confirmationMessage.append(getTaskId() + ": no update applicable for this task"); } return statements.toArray(new SqlStatement[statements.size()]); }