Program: 119255
Project: 119255
Buggy source:
/** 
 * DOC hwang Comment method "createConnection".
 */
public static DatabaseConnection createConnection(ConnectionParameters parameters){
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  String dbType=parameters.getDbType();
  boolean isNeedSchema=EDatabaseTypeName.getTypeFromDbType(dbType).isNeedSchema();
  String productName=EDatabaseTypeName.getTypeFromDisplayName(dbType).getProduct();
  String schema=parameters.getSchema();
  if (EDatabaseTypeName.TERADATA.getProduct().equals(productName)) {
    schema=parameters.getDbName();
  }
  if ("String_Node_Str".equals(schema) && EDatabaseTypeName.INFORMIX.getProduct().equals(productName)) {
    schema=parameters.getUserName();
  }
  if (EDatabaseTypeName.EXASOL.getProduct().equals(productName)) {
    schema=parameters.getDbName();
  }
  boolean isSchemaInValid=(schema == null) || (schema.equals("String_Node_Str")) || (schema.equals("String_Node_Str"))|| (schema.trim().equals("String_Node_Str"));
  NotReallyNeedSchemaDBS dbs=new NotReallyNeedSchemaDBS();
  dbs.init();
  List<String> names=dbs.getNeedSchemaDBNames();
  boolean ifNeedSchemaDB=names.contains(productName);
  if (isNeedSchema && isSchemaInValid && !ifNeedSchemaDB) {
    parameters.setConnectionComment(Messages.getString("String_Node_Str"));
    return null;
  }
  DatabaseConnection connection=ConnectionFactory.eINSTANCE.createDatabaseConnection();
  connection.setFileFieldName(parameters.getFilename());
  connection.setDatabaseType(dbType);
  connection.setUsername(parameters.getUserName());
  connection.setPort(parameters.getPort());
  connection.setRawPassword(parameters.getPassword());
  if (dbType != null && dbType.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName()) && parameters.getLocalServiceName() != null && !"String_Node_Str".equals(parameters.getLocalServiceName())) {
    connection.setSID(parameters.getLocalServiceName());
  }
 else {
    connection.setSID(parameters.getDbName());
  }
  connection.setLabel(parameters.getDbName());
  connection.setDatasourceName(parameters.getDatasource());
  if (parameters.getDbType().equals(EDatabaseTypeName.GODBC.getDisplayName()) && StringUtils.isEmpty(parameters.getDatasource())) {
    connection.setDatasourceName(parameters.getDbName());
  }
  if ("String_Node_Str".equals(connection.getLabel())) {
    connection.setLabel(parameters.getDatasource());
  }
  String driverClassByDbType=null;
  if (parameters.getDriverClass() != null) {
    driverClassByDbType=parameters.getDriverClass();
  }
 else {
    driverClassByDbType=extractMeta.getDriverClassByDbType(dbType);
  }
  String driverJar=parameters.getDriverJar();
  connection.setDriverClass(driverClassByDbType);
  connection.setDriverJarPath(driverJar);
  String databaseType=connection.getDatabaseType();
  if (driverClassByDbType != null && !"String_Node_Str".equals(driverClassByDbType) && EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(parameters.getDbType())) {
    if (driverClassByDbType.startsWith("String_Node_Str") && driverClassByDbType.endsWith("String_Node_Str")) {
      driverClassByDbType=TalendTextUtils.removeQuotes(driverClassByDbType);
    }
    String dbTypeByClassName="String_Node_Str";
    if (driverJar != null && !"String_Node_Str".equals(driverJar)) {
      dbTypeByClassName=extractMeta.getDbTypeByClassNameAndDriverJar(driverClassByDbType,driverJar);
    }
 else {
      dbTypeByClassName=extractMeta.getDbTypeByClassName(driverClassByDbType);
    }
    if (dbTypeByClassName != null) {
      databaseType=dbTypeByClassName;
    }
  }
  final String product=EDatabaseTypeName.getTypeFromDisplayName(databaseType).getProduct();
  ;
  connection.setProductId(product);
  if (MetadataTalendType.getDefaultDbmsFromProduct(product) != null) {
    final String mapping=MetadataTalendType.getDefaultDbmsFromProduct(product).getId();
    connection.setDbmsId(mapping);
  }
  if (!isSchemaInValid && isNeedSchema) {
    schema=schema.replaceAll("String_Node_Str","String_Node_Str");
    schema=schema.replaceAll("String_Node_Str","String_Node_Str");
    connection.setUiSchema(schema);
  }
  connection.setServerName(parameters.getHost());
  connection.setAdditionalParams(parameters.getJdbcProperties());
  connection.setURL(parameters.getCombineURL());
  connection.setDBRootPath(parameters.getDirectory());
  connection.setDbVersionString(parameters.getDbVersion());
  Map<String,String> params=parameters.getParameters();
  if (params != null && params.size() > 0) {
    Set<Entry<String,String>> collection=params.entrySet();
    for (    Entry<String,String> para : collection) {
      connection.getParameters().put(para.getKey(),para.getValue());
    }
  }
  return connection;
}

Fixed version (ground truth):
/** 
 * DOC hwang Comment method "createConnection".
 */
public static DatabaseConnection createConnection(ConnectionParameters parameters){
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  String dbType=parameters.getDbType();
  boolean isNeedSchema=EDatabaseTypeName.getTypeFromDbType(dbType).isNeedSchema();
  String productName=EDatabaseTypeName.getTypeFromDisplayName(dbType).getProduct();
  String schema=parameters.getSchema();
  EDatabaseTypeName type=EDatabaseTypeName.getTypeFromDbType(dbType);
  if (ManagerConnection.isSchemaFromSidOrDatabase(type)) {
    schema=parameters.getDbName();
  }
  if ("String_Node_Str".equals(schema) && EDatabaseTypeName.INFORMIX.getProduct().equals(productName)) {
    schema=parameters.getUserName();
  }
  if (EDatabaseTypeName.EXASOL.getProduct().equals(productName)) {
    schema=parameters.getDbName();
  }
  boolean isSchemaInValid=(schema == null) || (schema.equals("String_Node_Str")) || (schema.equals("String_Node_Str"))|| (schema.trim().equals("String_Node_Str"));
  NotReallyNeedSchemaDBS dbs=new NotReallyNeedSchemaDBS();
  dbs.init();
  List<String> names=dbs.getNeedSchemaDBNames();
  boolean ifNeedSchemaDB=names.contains(productName);
  if (isNeedSchema && isSchemaInValid && !ifNeedSchemaDB) {
    parameters.setConnectionComment(Messages.getString("String_Node_Str"));
    return null;
  }
  DatabaseConnection connection=ConnectionFactory.eINSTANCE.createDatabaseConnection();
  connection.setFileFieldName(parameters.getFilename());
  connection.setDatabaseType(dbType);
  connection.setUsername(parameters.getUserName());
  connection.setPort(parameters.getPort());
  connection.setRawPassword(parameters.getPassword());
  if (dbType != null && dbType.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName()) && parameters.getLocalServiceName() != null && !"String_Node_Str".equals(parameters.getLocalServiceName())) {
    connection.setSID(parameters.getLocalServiceName());
  }
 else {
    connection.setSID(parameters.getDbName());
  }
  connection.setLabel(parameters.getDbName());
  connection.setDatasourceName(parameters.getDatasource());
  if (parameters.getDbType().equals(EDatabaseTypeName.GODBC.getDisplayName()) && StringUtils.isEmpty(parameters.getDatasource())) {
    connection.setDatasourceName(parameters.getDbName());
  }
  if ("String_Node_Str".equals(connection.getLabel())) {
    connection.setLabel(parameters.getDatasource());
  }
  String driverClassByDbType=null;
  if (parameters.getDriverClass() != null) {
    driverClassByDbType=parameters.getDriverClass();
  }
 else {
    driverClassByDbType=extractMeta.getDriverClassByDbType(dbType);
  }
  String driverJar=parameters.getDriverJar();
  connection.setDriverClass(driverClassByDbType);
  connection.setDriverJarPath(driverJar);
  String databaseType=connection.getDatabaseType();
  if (driverClassByDbType != null && !"String_Node_Str".equals(driverClassByDbType) && EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(parameters.getDbType())) {
    if (driverClassByDbType.startsWith("String_Node_Str") && driverClassByDbType.endsWith("String_Node_Str")) {
      driverClassByDbType=TalendTextUtils.removeQuotes(driverClassByDbType);
    }
    String dbTypeByClassName="String_Node_Str";
    if (driverJar != null && !"String_Node_Str".equals(driverJar)) {
      dbTypeByClassName=extractMeta.getDbTypeByClassNameAndDriverJar(driverClassByDbType,driverJar);
    }
 else {
      dbTypeByClassName=extractMeta.getDbTypeByClassName(driverClassByDbType);
    }
    if (dbTypeByClassName != null) {
      databaseType=dbTypeByClassName;
    }
  }
  final String product=EDatabaseTypeName.getTypeFromDisplayName(databaseType).getProduct();
  ;
  connection.setProductId(product);
  if (MetadataTalendType.getDefaultDbmsFromProduct(product) != null) {
    final String mapping=MetadataTalendType.getDefaultDbmsFromProduct(product).getId();
    connection.setDbmsId(mapping);
  }
  if (!isSchemaInValid && isNeedSchema) {
    schema=schema.replaceAll("String_Node_Str","String_Node_Str");
    schema=schema.replaceAll("String_Node_Str","String_Node_Str");
    connection.setUiSchema(schema);
  }
  connection.setServerName(parameters.getHost());
  connection.setAdditionalParams(parameters.getJdbcProperties());
  connection.setURL(parameters.getCombineURL());
  connection.setDBRootPath(parameters.getDirectory());
  connection.setDbVersionString(parameters.getDbVersion());
  Map<String,String> params=parameters.getParameters();
  if (params != null && params.size() > 0) {
    Set<Entry<String,String>> collection=params.entrySet();
    for (    Entry<String,String> para : collection) {
      connection.getParameters().put(para.getKey(),para.getValue());
    }
  }
  return connection;
}