当我的结果集数据很大时,我会遇到
com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][4.9.78] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null
异常,但当我尝试在结果集中使用较少的数据时不会
下面是我的代码片段
ResultSet rs=null;
String sql_query="select * from exception_main;select * from m_roles"
String query1=sql_query.toUpperCase();
String[] results=query1.split(";");
CSVWriter writer = new CSVWriter(new FileWriter(csv_file_path + csv_file_name), ',',CSVWriter.NO_QUOTE_CHARACTER);
for(int i=0;i<results.length;i++)
{
if(results[i].startsWith("SELECT"))
{
System.out.println("Inside select"+ results[i]);
ps = conn1.prepareStatement(results[i].toString());
rs = ps.executeQuery();
...
//writing to csv file
System.out.println("Count..." + rs.getRow());
writer.writeAll(rs, true);
while(rs.next()){
rs.deleteRow();
}
System.out.println("Count...3:::::::" + rs1.getRow());
}
}
writer.close();
rs.close();