I I am getting below error Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null at com.ibm.db2.jcc.am.b6.a(b6.java:794) Also the output is Start time: 2024-03-28T12:59:39.726 Connection created for Database1: com.ibm.db2.jcc.t4.b@5e1218b4 There were 260 records. com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][4.25.13] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null Actually i am connecting to database but the above has been dispalyed. Please help in reolving the error
try {
// Create Statement Object
con = dbConnection();
Statement stmt = con.createStatement();
// Execute the SQL Query. Store results in ResultSet
rs = stmt.executeQuery(query);
int rowCount = 0;
while(rs.next())
{
rowCount++;
}
System.out.println("There were " + rowCount + " records.");
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
while (rs.next()) {
List<String> row = new ArrayList<>();
int i = 1;
while (i <= columnCount) {
row.add(rs.getString(i++));
}
result.add(row);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null!= con)
con.close();
}
return result;
}
}