This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Cursor Already Open ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Cursor Already Open ?" Watch "Cursor Already Open ?" New topic
Author

Cursor Already Open ?

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
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

Joined: Aug 02, 2004
Posts: 823
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

Joined: Feb 28, 2001
Posts: 455
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

Joined: Aug 02, 2004
Posts: 823
Why don't you just retrieve the description as part of the first ResultSet?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Cursor Already Open ?
 
Similar Threads
How to force cursor to update
XP and controlling "scope creep"
Two sessions started simultaneously, updating an object
Start up problem with Tomcat
help with database!