Source:
<code>public static boolean sequenceExists(Connection connection, String sequenceName) { boolean exists = false; PreparedStatement statement = null; ResultSet results = null; boolean schemaFilter = false; try { String schema = getSchemaName(connection); schema = canonicalize(connection, schema); String dbtype = DatabaseManager.findDbKeyword(connection.getMetaData()); String sequenceSQL = null; switch(dbtype) { case DatabaseManager.DBMS_POSTGRES: if(schema == null) { schema = "public"; } sequenceSQL = "SELECT COUNT(1) FROM pg_class, pg_namespace " + "WHERE pg_class.relnamespace=pg_namespace.oid " + "AND pg_class.relkind='S' " + "AND pg_class.relname=? " + "AND pg_namespace.nspname=?"; schemaFilter = true; break; case DatabaseManager.DBMS_ORACLE: sequenceSQL = "SELECT COUNT(1) FROM user_sequences WHERE sequence_name=?"; break; case DatabaseManager.DBMS_H2: sequenceSQL = "SELECT COUNT(1) " + "FROM INFORMATION_SCHEMA.SEQUENCES " + "WHERE SEQUENCE_NAME = ?"; break; default: throw new SQLException("DBMS " + dbtype + " is unsupported."); } if (sequenceSQL!=null) { statement = connection.prepareStatement(sequenceSQL); statement.setString(1, StringUtils.upperCase(sequenceName)); if(schemaFilter) { statement.setString(2, StringUtils.upperCase(schema)); } results = statement.executeQuery(); if(results!=null && results.next()) { if(results.getInt(1) > 0) { exists = true; <START> } <END> } } } catch(SQLException e) { log.error("Error attempting to determine if sequence " + sequenceName + " exists", e); } finally { try { if(statement!=null && !statement.isClosed()) statement.close(); if(results!=null && !results.isClosed()) results.close(); } catch(SQLException e) { } } return exists; }</code><technical_language>I this simply "exists = (results != null) && results.next() && (results.getInt(1) > 0);"</technical_language>

Target:
public static boolean sequenceExists(Connection connection, String sequenceName) { boolean exists = false; PreparedStatement statement = null; ResultSet results = null; boolean schemaFilter = false; try { String schema = getSchemaName(connection); schema = canonicalize(connection, schema); sequenceName = canonicalize(connection, sequenceName); String dbtype = DatabaseManager.findDbKeyword(connection.getMetaData()); String sequenceSQL = null; switch(dbtype) { case DatabaseManager.DBMS_POSTGRES: if(schema == null) { schema = "public"; } sequenceSQL = "SELECT COUNT(1) FROM pg_class, pg_namespace " + "WHERE pg_class.relnamespace=pg_namespace.oid " + "AND pg_class.relkind='S' " + "AND pg_class.relname=? " + "AND pg_namespace.nspname=?"; schemaFilter = true; break; case DatabaseManager.DBMS_ORACLE: sequenceSQL = "SELECT COUNT(1) FROM user_sequences WHERE sequence_name=?"; break; case DatabaseManager.DBMS_H2: sequenceSQL = "SELECT COUNT(1) " + "FROM INFORMATION_SCHEMA.SEQUENCES " + "WHERE SEQUENCE_NAME = ?"; break; default: throw new SQLException("DBMS " + dbtype + " is unsupported."); } if (sequenceSQL!=null) { statement = connection.prepareStatement(sequenceSQL); statement.setString(1, sequenceName); if(schemaFilter) { statement.setString(2, schema); } results = statement.executeQuery(); if(results!=null && results.next() && results.getInt(1)>0) { exists = true; } } } catch(SQLException e) { log.error("Error attempting to determine if sequence " + sequenceName + " exists", e); } finally { try { if(statement!=null && !statement.isClosed()) statement.close(); if(results!=null && !results.isClosed()) results.close(); } catch(SQLException e) { } } return exists; }