Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cursor Already Open ?

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I have a java app that is in use by our users. For some reason, that I have not been able to figure out, every once in a while, they will get a java.sql.exception Cursor C1 Already Open error message.
The first place it started happening was in Order Maintenance. They would key an order number, and if it was for a different customer than what they had selected, a JDialog would come up asking them if it's ok to change the customer. If they hit enter too fast (before the dialog comes up), the cursor error appears. It looks like I am closing all of my ResultSets / Callable Statements in finally clauses wherever there is database activity.

The second place this started happening was on a simple inquiry. Haven't quite pinpointed what actions cause this error yet.

Has anyone else had this problem? Could someone give me some other ideas of how to solve this problem??

Thanks!
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jennifer,

Hmmm, I smell a threading issue!

One possible solution that came to mind is to disable all the actions (buttons) on the parent JFrame before opening the JDialog. That way as soon as the JDialog is on its way, pressing Enter will have no effect. Closing the JDialog would then re-enable the actions.

If you're keen to get to the root cause, however, I would suggest putting some debug logging in the DB server code to log the opening and closing of the offending cursor(s). Make sure a stack trace is logged with the relevant SQLException. That way when the issue re-occurs in production you can analyse the log files and identify the root cause.

I hope you find this useful.

Jules
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I am reading through a result set, I am also calling a couple of static methods that call stored procedures. Do you think, this could be a possible issue? If so, what is an alternative solution?
While I am looping through my result set, each record has a part number, that I need to get the description for(which is the static DB method I am calling). I can't think of any other way to do this, besides making another DB call.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you just retrieve the description as part of the first ResultSet?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic