Program: 9730
Project: 9730
Buggy source:
public String executeSelectQuery(SparqlEndpoint endpoint,String query){
  try {
    byte[] md5=md5(query);
    PreparedStatement ps=conn.prepareStatement("String_Node_Str");
    ps.setBytes(1,md5);
    ResultSet rs=ps.executeQuery();
    boolean readFromCache=rs.next() && (rs.getTimestamp("String_Node_Str").getTime() - System.currentTimeMillis() < freshnessSeconds);
    if (readFromCache) {
      Clob clob=rs.getClob("String_Node_Str");
      return clob.getSubString(1,(int)clob.length());
    }
 else {
      QueryEngineHTTP queryExecution=new QueryEngineHTTP(endpoint.getURL().toString(),query);
      for (      String dgu : endpoint.getDefaultGraphURIs()) {
        queryExecution.addDefaultGraph(dgu);
      }
      for (      String ngu : endpoint.getNamedGraphURIs()) {
        queryExecution.addNamedGraph(ngu);
      }
      com.hp.hpl.jena.query.ResultSet tmp=queryExecution.execSelect();
      ResultSetRewindable rs2=ResultSetFactory.makeRewindable(tmp);
      String json=SparqlQuery.convertResultSetToJSON(rs2);
      PreparedStatement ps2=conn.prepareStatement("String_Node_Str");
      ps2.setBytes(1,md5);
      ps2.setString(2,query);
      ps2.setClob(3,new StringReader(json));
      ps2.setTimestamp(4,new java.sql.Timestamp(new java.util.Date().getTime()));
      ps2.executeUpdate();
      return json;
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
public String executeSelectQuery(SparqlEndpoint endpoint,String query){
  try {
    byte[] md5=md5(query);
    PreparedStatement ps=conn.prepareStatement("String_Node_Str");
    ps.setBytes(1,md5);
    ResultSet rs=ps.executeQuery();
    boolean entryExists=rs.next();
    boolean readFromCache=entryExists && (System.currentTimeMillis() - rs.getTimestamp("String_Node_Str").getTime() < freshnessInMilliseconds);
    if (readFromCache) {
      Clob clob=rs.getClob("String_Node_Str");
      return clob.getSubString(1,(int)clob.length());
    }
 else {
      QueryEngineHTTP queryExecution=new QueryEngineHTTP(endpoint.getURL().toString(),query);
      for (      String dgu : endpoint.getDefaultGraphURIs()) {
        queryExecution.addDefaultGraph(dgu);
      }
      for (      String ngu : endpoint.getNamedGraphURIs()) {
        queryExecution.addNamedGraph(ngu);
      }
      com.hp.hpl.jena.query.ResultSet tmp=queryExecution.execSelect();
      ResultSetRewindable rs2=ResultSetFactory.makeRewindable(tmp);
      String json=SparqlQuery.convertResultSetToJSON(rs2);
      PreparedStatement ps2;
      if (entryExists) {
        ps2=conn.prepareStatement("String_Node_Str");
        ps2.setClob(1,new StringReader(json));
        ps2.setTimestamp(2,new java.sql.Timestamp(new java.util.Date().getTime()));
        ps2.setBytes(3,md5);
      }
 else {
        ps2=conn.prepareStatement("String_Node_Str");
        ps2.setBytes(1,md5);
        ps2.setString(2,query);
        ps2.setClob(3,new StringReader(json));
        ps2.setTimestamp(4,new java.sql.Timestamp(new java.util.Date().getTime()));
      }
      ps2.executeUpdate();
      return json;
    }
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
}