Program: 87042
Project: 87042
Buggy source:
public void fillInsertStatementFromResultSet(final String sourceConnectorId,final TableMetaData sourceTableMetaData,final String targetConnectorId,final TableMetaData targetTableMetaData,final TargetDatabaseConfiguration targetDatabaseConfiguration,final Connection targetConnection,final ResultSet rs,final PreparedStatement insertStatement,final int numberOfRowsPerBatch,final boolean useMultipleValuesClauses) throws SQLException {
  final CommonColumnTypeResolverTool commonColumnTypeResolver=new CommonColumnTypeResolverTool(_connectorRepository);
  final List<ColumnMetaData> sourceColumns=ColumnOrderHint.getSortedColumns(_connectorRepository,sourceConnectorId,sourceTableMetaData);
  final ColumnMapper columnMapper=_connectorRepository.getConnectorHint(targetConnectorId,ColumnMapper.class).getValue();
  final DatabaseType targetDatabaseType=targetTableMetaData.getDatabaseMetaData().getDatabaseType();
  int currentIndex=1;
  int dataItemsCount=0;
  for (int currentRow=0; currentRow < numberOfRowsPerBatch; currentRow++) {
    final boolean ok=rs.next();
    if (!ok) {
      throw new MissingDataException("String_Node_Str" + currentRow + "String_Node_Str"+ numberOfRowsPerBatch);
    }
    targetDatabaseConfiguration.beforeNewRow(targetConnection,targetConnectorId,targetTableMetaData);
    for (int columnIndex=1; columnIndex <= sourceColumns.size(); columnIndex++) {
      final ColumnMetaData columnMetaData1=sourceColumns.get(columnIndex - 1);
      final ColumnMapperResult mapping=columnMapper.map(columnMetaData1,targetTableMetaData);
      for (      final ColumnMetaData columnMetaData2 : mapping.getColumns()) {
        final ColumnTypeMapping columnTypeMapping=findMapping(sourceConnectorId,targetConnectorId,commonColumnTypeResolver,columnMetaData1,columnMetaData2);
        Object value=columnTypeMapping.getSourceColumnType().getValue(rs,columnIndex);
        value=columnTypeMapping.getColumnDataMapper().map(columnMetaData1,columnMetaData2,value);
        columnTypeMapping.getTargetColumnType().setValue(insertStatement,currentIndex++,value,targetDatabaseType,columnMetaData2.getColumnType());
        dataItemsCount++;
      }
    }
    if (!useMultipleValuesClauses) {
      insertStatement.addBatch();
      currentIndex=1;
    }
    targetDatabaseConfiguration.afterNewRow(targetConnection,targetConnectorId,targetTableMetaData);
  }
  if (useMultipleValuesClauses) {
    insertStatement.addBatch();
  }
  LOG.debug("String_Node_Str" + dataItemsCount);
}

Fixed version (ground truth):
public void fillInsertStatementFromResultSet(final String sourceConnectorId,final TableMetaData sourceTableMetaData,final String targetConnectorId,final TableMetaData targetTableMetaData,final TargetDatabaseConfiguration targetDatabaseConfiguration,final Connection targetConnection,final ResultSet rs,final PreparedStatement insertStatement,final int numberOfRowsPerBatch,final boolean useMultipleValuesClauses) throws SQLException {
  final CommonColumnTypeResolverTool commonColumnTypeResolver=new CommonColumnTypeResolverTool(_connectorRepository);
  final List<ColumnMetaData> sourceColumns=ColumnOrderHint.getSortedColumns(_connectorRepository,sourceConnectorId,sourceTableMetaData);
  final ColumnMapper columnMapper=_connectorRepository.getConnectorHint(targetConnectorId,ColumnMapper.class).getValue();
  final DatabaseType targetDatabaseType=targetTableMetaData.getDatabaseMetaData().getDatabaseType();
  int targetColumnIndex=1;
  int dataItemsCount=0;
  for (int currentRow=0; currentRow < numberOfRowsPerBatch; currentRow++) {
    final boolean ok=rs.next();
    if (!ok) {
      throw new MissingDataException("String_Node_Str" + currentRow + "String_Node_Str"+ numberOfRowsPerBatch);
    }
    targetDatabaseConfiguration.beforeNewRow(targetConnection,targetConnectorId,targetTableMetaData);
    for (int columnIndex=1; columnIndex <= sourceColumns.size(); columnIndex++) {
      final ColumnMetaData columnMetaData1=sourceColumns.get(columnIndex - 1);
      final ColumnMapperResult mapping=columnMapper.map(columnMetaData1,targetTableMetaData);
      if (mapping.getColumns().isEmpty()) {
        if (mapping.isEmptyColumnListOk()) {
          rs.getObject(columnIndex);
        }
 else {
          throw new IncompatibleColumnsException("String_Node_Str" + targetTableMetaData + "String_Node_Str"+ columnMetaData1+ "String_Node_Str");
        }
      }
      for (      final ColumnMetaData columnMetaData2 : mapping.getColumns()) {
        final ColumnTypeMapping columnTypeMapping=findMapping(sourceConnectorId,targetConnectorId,commonColumnTypeResolver,columnMetaData1,columnMetaData2);
        Object value=columnTypeMapping.getSourceColumnType().getValue(rs,columnIndex);
        value=columnTypeMapping.getColumnDataMapper().map(columnMetaData1,columnMetaData2,value);
        columnTypeMapping.getTargetColumnType().setValue(insertStatement,targetColumnIndex++,value,targetDatabaseType,columnMetaData2.getColumnType());
        dataItemsCount++;
      }
    }
    if (!useMultipleValuesClauses) {
      insertStatement.addBatch();
      targetColumnIndex=1;
    }
    targetDatabaseConfiguration.afterNewRow(targetConnection,targetConnectorId,targetTableMetaData);
  }
  if (useMultipleValuesClauses) {
    insertStatement.addBatch();
  }
  LOG.debug("String_Node_Str" + dataItemsCount);
}