Program: 24992
Project: 24992
Buggy source:
/** 
 * <p>Tell whether the specified column exists in the specified table of the database. To do so, it is using the given   {@link DatabaseMetaData} object to query the database and list all existing columns.</p><p><i><b>Important note:</b> If schemas are not supported by this connection but a schema name is even though provided in parameter, the table name will be prefixed by the schema name. The research will then be done with NULL as schema name and this prefixed table name. </i></p> <p><i>Note: Test on the schema name is done considering the case sensitivity indicated by the translator (see  {@link JDBCTranslator#isCaseSensitive(IdentifierField)}). </i></p> <p><i>Note: This function is used by   {@link #loadSchemas(TAPTable,TAPMetadata,Statement)},   {@link #loadTables(TAPTable,TAPMetadata,Statement)}and   {@link #loadColumns(TAPTable,List,Statement)}. </i></p>
 * @param schemaName	DB name of the table schema. <i>MAY BE NULL</i>
 * @param tableName		DB name of the table containing the column to search. <i>MAY BE NULL</i>
 * @param columnName	DB name of the column to search.
 * @param dbMeta		Metadata about the database, and mainly the list of all existing tables.
 * @return	<i>true</i> if the specified column exists, <i>false</i> otherwise.
 * @throws SQLException	If any error occurs while interrogating the database about existing columns.
 */
protected boolean isColumnExisting(String schemaName,String tableName,String columnName,final DatabaseMetaData dbMeta) throws DBException, SQLException {
  if (columnName == null || columnName.length() == 0)   return true;
  boolean schemaCaseSensitive=translator.isCaseSensitive(IdentifierField.SCHEMA);
  boolean tableCaseSensitive=translator.isCaseSensitive(IdentifierField.TABLE);
  boolean columnCaseSensitive=translator.isCaseSensitive(IdentifierField.COLUMN);
  ResultSet rsT=null, rsC=null;
  try {
    if (supportsSchema) {
      String schemaPattern=schemaCaseSensitive ? schemaName : null;
      String tablePattern=tableCaseSensitive ? tableName : null;
      rsT=dbMeta.getTables(null,schemaPattern,tablePattern,null);
    }
 else {
      String tablePattern=tableCaseSensitive ? tableName : null;
      rsT=dbMeta.getTables(null,null,tablePattern,null);
    }
    int cnt=0;
    String columnPattern=columnCaseSensitive ? columnName : null;
    while (rsT.next()) {
      int rsTSchemaIndex=dbms.equalsIgnoreCase(DBMS_MYSQL) ? 1 : 2;
      String rsSchema=nullifyIfNeeded(rsT.getString(rsTSchemaIndex));
      String rsTable=rsT.getString(3);
      if (!supportsSchema || schemaName == null || equals(rsSchema,schemaName,schemaCaseSensitive)) {
        if ((tableName == null || equals(rsTable,tableName,tableCaseSensitive))) {
          rsC=dbMeta.getColumns(null,rsSchema,rsTable,columnPattern);
          while (rsC.next()) {
            String rsColumn=rsC.getString(4);
            if (equals(rsColumn,columnName,columnCaseSensitive))             cnt++;
          }
          close(rsC);
        }
      }
    }
    if (cnt > 1) {
      if (logger != null)       logger.logDB(LogLevel.ERROR,this,"String_Node_Str","String_Node_Str" + schemaName + "String_Node_Str"+ schemaCaseSensitive+ "String_Node_Str"+ tableName+ "String_Node_Str"+ tableCaseSensitive+ "String_Node_Str"+ columnName+ "String_Node_Str"+ columnCaseSensitive+ "String_Node_Str",null);
      throw new DBException("String_Node_Str" + schemaName + "String_Node_Str"+ schemaCaseSensitive+ "String_Node_Str"+ tableName+ "String_Node_Str"+ tableCaseSensitive+ "String_Node_Str"+ columnName+ "String_Node_Str"+ columnCaseSensitive+ "String_Node_Str");
    }
    return cnt == 1;
  }
  finally {
    close(rsT);
    close(rsC);
  }
}

Fixed version (ground truth):
/** 
 * <p>Tell whether the specified column exists in the specified table of the database. To do so, it is using the given   {@link DatabaseMetaData} object to query the database and list all existing columns.</p><p><i><b>Important note:</b> If schemas are not supported by this connection but a schema name is even though provided in parameter, the table name will be prefixed by the schema name. The research will then be done with NULL as schema name and this prefixed table name. </i></p> <p><i>Note: Test on the schema name is done considering the case sensitivity indicated by the translator (see  {@link JDBCTranslator#isCaseSensitive(IdentifierField)}). </i></p> <p><i>Note: This function is used by   {@link #loadSchemas(TAPTable,TAPMetadata,Statement)},   {@link #loadTables(TAPTable,TAPMetadata,Statement)}and   {@link #loadColumns(TAPTable,List,Statement)}. </i></p>
 * @param schemaName	DB name of the table schema. <i>MAY BE NULL</i>
 * @param tableName		DB name of the table containing the column to search. <i>MAY BE NULL</i>
 * @param columnName	DB name of the column to search.
 * @param dbMeta		Metadata about the database, and mainly the list of all existing tables.
 * @return	<i>true</i> if the specified column exists, <i>false</i> otherwise.
 * @throws SQLException	If any error occurs while interrogating the database about existing columns.
 */
protected boolean isColumnExisting(String schemaName,String tableName,String columnName,final DatabaseMetaData dbMeta) throws DBException, SQLException {
  if (columnName == null || columnName.length() == 0)   return true;
  boolean schemaCaseSensitive=translator.isCaseSensitive(IdentifierField.SCHEMA);
  boolean tableCaseSensitive=translator.isCaseSensitive(IdentifierField.TABLE);
  boolean columnCaseSensitive=translator.isCaseSensitive(IdentifierField.COLUMN);
  ResultSet rsT=null, rsC=null;
  try {
    if (supportsSchema) {
      String schemaPattern=schemaCaseSensitive ? schemaName : null;
      String tablePattern=tableCaseSensitive ? tableName : null;
      rsT=getDBMetaTables(dbMeta,schemaPattern,tablePattern);
    }
 else {
      String tablePattern=tableCaseSensitive ? tableName : null;
      rsT=getDBMetaTables(dbMeta,null,tablePattern);
    }
    int cnt=0;
    String columnPattern=columnCaseSensitive ? columnName : null;
    while (rsT.next()) {
      String rsSchema=nullifyIfNeeded(rsT.getString(getTableSchemaIndexInMetadata()));
      String rsTable=rsT.getString(3);
      if (!supportsSchema || schemaName == null || equals(rsSchema,schemaName,schemaCaseSensitive)) {
        if ((tableName == null || equals(rsTable,tableName,tableCaseSensitive))) {
          rsC=getDBMetaColumns(dbMeta,rsSchema,rsTable,columnPattern);
          while (rsC.next()) {
            String rsColumn=rsC.getString(4);
            if (equals(rsColumn,columnName,columnCaseSensitive))             cnt++;
          }
          close(rsC);
        }
      }
    }
    if (cnt > 1) {
      if (logger != null)       logger.logDB(LogLevel.ERROR,this,"String_Node_Str","String_Node_Str" + schemaName + "String_Node_Str"+ schemaCaseSensitive+ "String_Node_Str"+ tableName+ "String_Node_Str"+ tableCaseSensitive+ "String_Node_Str"+ columnName+ "String_Node_Str"+ columnCaseSensitive+ "String_Node_Str",null);
      throw new DBException("String_Node_Str" + schemaName + "String_Node_Str"+ schemaCaseSensitive+ "String_Node_Str"+ tableName+ "String_Node_Str"+ tableCaseSensitive+ "String_Node_Str"+ columnName+ "String_Node_Str"+ columnCaseSensitive+ "String_Node_Str");
    }
    return cnt == 1;
  }
  finally {
    close(rsT);
    close(rsC);
  }
}