• Post Reply Bookmark Topic Watch Topic
  • New Topic

error in jdbc  RSS feed

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jdbc class that prints same result 10000 times,but it throws exception as show
java.sql.SQLException: ORA-01000: maximum open cursors exceeded

i know i can increase max number of cursors in oracle db.but db is located somewhere else so i cant do that.the code below throws exception when value of i=300.my requirement is that loop should print resultset 10000 times without any error.Code is show below please help me.
-----code-----------------------
for(10000 times)
{
String qs = "select * from scheduledJobs";
stmt = con.createStatement();
rs = stmt.executeQuery(qs);
while (rs.next()){
System.out.print(rs.getString("jobid");
System.out.print(rs.getString("interfaceid"));
}

rs.close();
stmt.close();
con.close();
}
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, not even close to being included in Jobs Wanted, moving to JDBC

Jamie
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37399
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gowher,
The problem is that you are opening resources (statement and result set) within the loop, but closing them outside the loop. Try moving the close calls to within the loop, preferably in a finally block.

So the database resources never get returned and the db runs out of cursors for the result sets.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!