Program: 19679
Project: 19679
Buggy source:
private int initialiseSimulation(String comment,String sim_uuid,Boolean remote) throws SQLException {
  PreparedStatement simAdd=conn.prepareStatement(Statements.addSim.getPrototype());
  simAdd.setString(1,sim_uuid);
  String userName=System.getProperty("String_Node_Str");
  logger.log(Level.INFO,"String_Node_Str",userName);
  if (remote) {
    PreparedStatement userAdd=conn.prepareStatement(Statements.addUser.getPrototype());
    userAdd.setString(1,userName);
    userAdd.setString(2,userName);
    userAdd.setString(3,"String_Node_Str");
    userAdd.executeUpdate();
    ResultSet rs=userAdd.getGeneratedKeys();
    int userId=0;
    if (rs.next())     userId=rs.getInt(1);
 else     logger.log(Level.WARNING,"String_Node_Str");
    rs.close();
    userAdd.close();
    logger.log(Level.INFO,"String_Node_Str",userId);
    simAdd.setInt(2,userId);
  }
 else {
    simAdd.setString(2,userName);
  }
  simAdd.setString(3,comment);
  simAdd.executeUpdate();
  logger.log(Level.INFO,"String_Node_Str",comment);
  ResultSet rs=simAdd.getGeneratedKeys();
  int simulationId=0;
  if (rs.next())   simulationId=rs.getInt(1);
 else   logger.log(Level.WARNING,"String_Node_Str");
  rs.close();
  simAdd.close();
  logger.log(Level.INFO,"String_Node_Str",simulationId);
  if (!conn.getAutoCommit())   conn.commit();
  newAgent.setInt(1,simulationId);
  dieAgent.setInt(2,simulationId);
  roundAgent.setInt(1,simulationId);
  newGroup.setInt(1,simulationId);
  dieGroup.setInt(2,simulationId);
  roundGroup.setInt(1,simulationId);
  endAgent.setInt(2,simulationId);
  endGroup.setInt(2,simulationId);
  endSim.setInt(2,simulationId);
  return simulationId;
}

Fixed version (ground truth):
private int initialiseSimulation(String comment,String sim_uuid,Boolean remote) throws SQLException {
  PreparedStatement simAdd=conn.prepareStatement(Statements.addSim.getPrototype());
  simAdd.setString(1,sim_uuid);
  String userName=System.getProperty("String_Node_Str");
  logger.log(Level.INFO,"String_Node_Str",userName);
  if (remote) {
    PreparedStatement userAdd=conn.prepareStatement(Statements.addUser.getPrototype());
    userAdd.setString(1,userName);
    userAdd.setString(2,userName);
    userAdd.setString(3,"String_Node_Str");
    userAdd.executeUpdate();
    ResultSet rs=userAdd.getGeneratedKeys();
    int userId=0;
    if (rs.next())     userId=rs.getInt(1);
 else     logger.log(Level.WARNING,"String_Node_Str");
    rs.close();
    userAdd.close();
    logger.log(Level.INFO,"String_Node_Str",userId);
    simAdd.setInt(2,userId);
  }
 else {
    simAdd.setString(2,userName);
  }
  simAdd.setString(3,comment);
  simAdd.executeUpdate();
  logger.log(Level.INFO,"String_Node_Str",comment);
  ResultSet rs=simAdd.getGeneratedKeys();
  int simulationId=0;
  if (rs.next())   simulationId=rs.getInt(1);
 else   logger.log(Level.WARNING,"String_Node_Str");
  rs.close();
  simAdd.close();
  logger.log(Level.INFO,"String_Node_Str",simulationId);
  if (!conn.getAutoCommit())   conn.commit();
  newAgent.setInt(1,simulationId);
  dieAgent.setInt(2,simulationId);
  roundAgent.setInt(1,simulationId);
  trustAgent.setInt(1,simulationId);
  newGroup.setInt(1,simulationId);
  dieGroup.setInt(2,simulationId);
  roundGroup.setInt(1,simulationId);
  endAgent.setInt(2,simulationId);
  endGroup.setInt(2,simulationId);
  endSim.setInt(2,simulationId);
  return simulationId;
}