Program: 105267
Project: 105267
Buggy source:
private void encryptLdapConfigParams(Connection conn){
  PreparedStatement pstmt=null;
  String[][] ldapParams={{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"}};
  String insertSql="String_Node_Str" + "String_Node_Str";
  try {
    pstmt=conn.prepareStatement(insertSql);
    for (    String[] ldapParam : ldapParams) {
      String name=ldapParam[0];
      String value=ldapParam[1];
      String desc=ldapParam[2];
      String encryptedValue=DBEncryptionUtil.encrypt(value);
      pstmt.setString(1,name);
      pstmt.setBytes(2,encryptedValue.getBytes("String_Node_Str"));
      pstmt.setString(3,desc);
      pstmt.executeUpdate();
    }
    pstmt.close();
    pstmt=conn.prepareStatement("String_Node_Str");
    ResultSet resultSet=pstmt.executeQuery();
    String hostname=null;
    String port;
    int portNumber=0;
    if (resultSet.next()) {
      hostname=DBEncryptionUtil.decrypt(resultSet.getString(1));
    }
    pstmt.close();
    pstmt=conn.prepareStatement("String_Node_Str");
    resultSet=pstmt.executeQuery();
    if (resultSet.next()) {
      port=DBEncryptionUtil.decrypt(resultSet.getString(1));
      if (StringUtils.isNotBlank(port)) {
        portNumber=Integer.valueOf(port);
      }
    }
    pstmt.close();
    if (StringUtils.isNotBlank(hostname)) {
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setString(1,hostname);
      if (portNumber != 0) {
        pstmt.setInt(2,portNumber);
      }
 else {
        pstmt.setNull(2,Types.INTEGER);
      }
      pstmt.executeUpdate();
      pstmt.close();
    }
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
catch (  UnsupportedEncodingException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
 finally {
    try {
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
  s_logger.debug("String_Node_Str");
}

Fixed version (ground truth):
private void encryptLdapConfigParams(Connection conn){
  PreparedStatement pstmt=null;
  String[][] ldapParams={{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str","String_Node_Str"}};
  String insertSql="String_Node_Str" + "String_Node_Str";
  try {
    pstmt=conn.prepareStatement(insertSql);
    for (    String[] ldapParam : ldapParams) {
      String name=ldapParam[0];
      String value=ldapParam[1];
      String desc=ldapParam[2];
      String encryptedValue=DBEncryptionUtil.encrypt(value);
      pstmt.setString(1,name);
      pstmt.setBytes(2,encryptedValue.getBytes("String_Node_Str"));
      pstmt.setString(3,desc);
      pstmt.executeUpdate();
    }
    pstmt.close();
    pstmt=conn.prepareStatement("String_Node_Str");
    ResultSet resultSet=pstmt.executeQuery();
    String hostname=null;
    String port;
    int portNumber=0;
    if (resultSet.next()) {
      hostname=DBEncryptionUtil.decrypt(resultSet.getString(1));
    }
    pstmt.close();
    pstmt=conn.prepareStatement("String_Node_Str");
    resultSet=pstmt.executeQuery();
    if (resultSet.next()) {
      port=DBEncryptionUtil.decrypt(resultSet.getString(1));
      if (StringUtils.isNotBlank(port)) {
        portNumber=Integer.parseInt(port);
      }
    }
    pstmt.close();
    if (StringUtils.isNotBlank(hostname)) {
      pstmt=conn.prepareStatement("String_Node_Str");
      pstmt.setString(1,hostname);
      if (portNumber != 0) {
        pstmt.setInt(2,portNumber);
      }
 else {
        pstmt.setNull(2,Types.INTEGER);
      }
      pstmt.executeUpdate();
      pstmt.close();
    }
  }
 catch (  SQLException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
catch (  UnsupportedEncodingException e) {
    throw new CloudRuntimeException("String_Node_Str",e);
  }
 finally {
    try {
      if (pstmt != null) {
        pstmt.close();
      }
    }
 catch (    SQLException e) {
    }
  }
  s_logger.debug("String_Node_Str");
}