Program: 84124
Project: 84124
Buggy source:
/** 
 * This method will check the database ChangeLogLock table used to keep track of if a machine is updating the database. If the table does not exist it will create one otherwise it will not do anything besides outputting a log message.
 */
public void checkDatabaseChangeLogLockTable() throws JDBCException {
  DatabaseConnection connection=getConnection();
  ResultSet rs=null;
  boolean knowMustInsertIntoLockTable=false;
  try {
    rs=connection.getMetaData().getTables(convertRequestedSchemaToCatalog(getDefaultSchemaName()),convertRequestedSchemaToSchema(getDefaultSchemaName()),getDatabaseChangeLogLockTableName(),new String[]{"String_Node_Str"});
    if (!rs.next()) {
      if (!changeLogLockCreateAttempted) {
        changeLogLockCreateAttempted=true;
        SqlStatement createTableStatement=getCreateChangeLogLockSQL();
        getJdbcTemplate().comment("String_Node_Str");
        this.getJdbcTemplate().execute(createTableStatement);
        this.commit();
        log.info("String_Node_Str" + getDatabaseChangeLogLockTableName());
        changeLogLockTableExists=true;
        knowMustInsertIntoLockTable=true;
      }
    }
 else {
      changeLogLockTableExists=true;
    }
    rs.close();
    if (changeLogLockTableExists) {
      int rows=-1;
      if (!knowMustInsertIntoLockTable) {
        RawSqlStatement selectStatement=new RawSqlStatement("String_Node_Str" + getDatabaseChangeLogLockTableName() + "String_Node_Str");
        rows=this.getJdbcTemplate().queryForInt(selectStatement);
      }
      if (knowMustInsertIntoLockTable || rows == 0) {
        this.getJdbcTemplate().update(getChangeLogLockInsertSQL());
        this.commit();
        log.info("String_Node_Str" + getDatabaseChangeLogLockTableName());
        rs.close();
      }
    }
 else {
      throw new JDBCException("String_Node_Str");
    }
  }
 catch (  SQLException e) {
    throw new JDBCException(e);
  }
 finally {
    if (rs != null) {
      try {
        rs.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method will check the database ChangeLogLock table used to keep track of if a machine is updating the database. If the table does not exist it will create one otherwise it will not do anything besides outputting a log message.
 */
public void checkDatabaseChangeLogLockTable() throws JDBCException {
  DatabaseConnection connection=getConnection();
  ResultSet rs=null;
  boolean knowMustInsertIntoLockTable=false;
  try {
    rs=connection.getMetaData().getTables(convertRequestedSchemaToCatalog(getDefaultSchemaName()),convertRequestedSchemaToSchema(getDefaultSchemaName()),getDatabaseChangeLogLockTableName(),new String[]{"String_Node_Str"});
    if (!rs.next()) {
      if (!changeLogLockCreateAttempted) {
        changeLogLockCreateAttempted=true;
        SqlStatement createTableStatement=getCreateChangeLogLockSQL();
        getJdbcTemplate().comment("String_Node_Str");
        this.getJdbcTemplate().execute(createTableStatement);
        this.commit();
        log.info("String_Node_Str" + escapeTableName(getDefaultSchemaName(),getDatabaseChangeLogLockTableName()));
        changeLogLockTableExists=true;
        knowMustInsertIntoLockTable=true;
      }
    }
 else {
      changeLogLockTableExists=true;
    }
    rs.close();
    if (changeLogLockTableExists) {
      int rows=-1;
      if (!knowMustInsertIntoLockTable) {
        RawSqlStatement selectStatement=new RawSqlStatement("String_Node_Str" + escapeTableName(getDefaultSchemaName(),getDatabaseChangeLogLockTableName()) + "String_Node_Str");
        rows=this.getJdbcTemplate().queryForInt(selectStatement);
      }
      if (knowMustInsertIntoLockTable || rows == 0) {
        this.getJdbcTemplate().update(getChangeLogLockInsertSQL());
        this.commit();
        log.info("String_Node_Str" + escapeTableName(getDefaultSchemaName(),getDatabaseChangeLogLockTableName()));
        rs.close();
      }
    }
 else {
      throw new JDBCException("String_Node_Str");
    }
  }
 catch (  SQLException e) {
    throw new JDBCException(e);
  }
 finally {
    if (rs != null) {
      try {
        rs.close();
      }
 catch (      SQLException e) {
        throw new JDBCException(e);
      }
    }
  }
}