-1

I have a query that retrieves 2500 records in MySQL database. The problem is that its causing the GC overhead limit exceeded error in java. I don't know how to optimize my query to prevent his from happening. This is the code:

public static List<List<String>> getLogs(){
    sql = new String("SELECT EmpID, ValidDate, GROUP_CONCAT(ValidTime ORDER BY ValidTime ASC) AS logTime FROM logs WHERE Processed = 0 GROUP BY EmpID, ValidDate ORDER BY ValidDate ASC");
    List<List<String>> values = new ArrayList<>();
    List<String> id = new ArrayList<>();
    List<String> valDate = new ArrayList<>();
    List<String> logs = new ArrayList<>();

    try{
        stmt = data.createStatement();
        rs = stmt.executeQuery(sql);

        while(rs.next()){
            id.add(rs.getString("EmpID"));
            valDate.add(String.valueOf(rs.getDate("ValidDate"))); // This line of code produces the error mentioned in stacktrace
            logs.add(rs.getString("logTime"));
        }
    }catch(SQLException ex){
        ex.printStackTrace();
    }
    values.add(id);
    values.add(valDate);
    values.add(logs);

    return values;
}
SilverRay
  • 331
  • 2
  • 7
  • 23

1 Answers1

0

I solved my problem by just adding rs.close() in my code. Thanks for the responses and why's the downvote?

SilverRay
  • 331
  • 2
  • 7
  • 23