Program: 175095
Project: 175095
Buggy source:
public static List<ImagePlanning> getImagePlanning(String dbname) throws Exception {
  List<ImagePlanning> listImageplanning=new ArrayList<ImagePlanning>();
  Connection conn=DriverManager.getConnection("String_Node_Str" + dbname + "String_Node_Str","String_Node_Str","String_Node_Str");
  Statement stat=conn.createStatement();
  String sql="String_Node_Str";
  ResultSet res=stat.executeQuery(sql);
  WKTReader wktr=new WKTReader();
  Geometry imageGeom=null;
  while (!res.isClosed() && res.next()) {
    ImagePlanning imagePlanning=new ImagePlanning();
    imagePlanning.setName(res.getString("String_Node_Str"));
    imagePlanning.setAcquisitionTime(Timestamp.valueOf(res.getString("String_Node_Str")));
    imagePlanning.setAcquisitionStopTime(Timestamp.valueOf(res.getString("String_Node_Str")));
    imagePlanning.setRemoteLocation(new URL(res.getString("String_Node_Str")));
    imagePlanning.setAction(res.getString("String_Node_Str"));
    try {
      imageGeom=wktr.read(res.getString("String_Node_Str"));
    }
 catch (    Exception e) {
      imageGeom=null;
    }
    imagePlanning.setArea(imageGeom);
    if (imagePlanning.getAcquisitionStopTime().getTime() - System.currentTimeMillis() < 0) {
      try {
        stat.execute("String_Node_Str" + res.getString("String_Node_Str") + "String_Node_Str"+ res.getString("String_Node_Str")+ "String_Node_Str");
      }
 catch (      Exception e) {
        System.out.println("String_Node_Str" + res.getString("String_Node_Str"));
      }
    }
 else {
      listImageplanning.add(imagePlanning);
    }
  }
  stat.close();
  conn.close();
  return listImageplanning;
}

Fixed version (ground truth):
public static List<ImagePlanning> getImagePlanning(String dbname) throws Exception {
  List<ImagePlanning> listImageplanning=new ArrayList<ImagePlanning>();
  Connection conn=DriverManager.getConnection("String_Node_Str" + dbname + "String_Node_Str","String_Node_Str","String_Node_Str");
  String sqlCheckEx="String_Node_Str";
  Statement statEx=conn.createStatement();
  ResultSet res=statEx.executeQuery(sqlCheckEx);
  res.next();
  int count=res.getInt(1);
  if (count != 0) {
    Statement stat=conn.createStatement();
    String sql="String_Node_Str";
    res=stat.executeQuery(sql);
    WKTReader wktr=new WKTReader();
    Geometry imageGeom=null;
    while (!res.isClosed() && res.next()) {
      ImagePlanning imagePlanning=new ImagePlanning();
      imagePlanning.setName(res.getString("String_Node_Str"));
      imagePlanning.setAcquisitionTime(Timestamp.valueOf(res.getString("String_Node_Str")));
      imagePlanning.setAcquisitionStopTime(Timestamp.valueOf(res.getString("String_Node_Str")));
      imagePlanning.setRemoteLocation(new URL(res.getString("String_Node_Str")));
      imagePlanning.setAction(res.getString("String_Node_Str"));
      try {
        imageGeom=wktr.read(res.getString("String_Node_Str"));
      }
 catch (      Exception e) {
        imageGeom=null;
      }
      imagePlanning.setArea(imageGeom);
      if (imagePlanning.getAcquisitionStopTime().getTime() - System.currentTimeMillis() < 0) {
        try {
          stat.execute("String_Node_Str" + res.getString("String_Node_Str") + "String_Node_Str"+ res.getString("String_Node_Str")+ "String_Node_Str");
        }
 catch (        Exception e) {
          System.out.println("String_Node_Str" + res.getString("String_Node_Str"));
        }
      }
 else {
        listImageplanning.add(imagePlanning);
      }
    }
    stat.close();
    statEx.close();
    conn.close();
  }
  return listImageplanning;
}