Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code being blocked by ResultSet.execute

 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys,
have you had your code being blocked by a call to ResultSet.execute(sql)?? some times, when someone is locking some resource in the data base and I try to use the same resource the Data base puts my request in a stack to wait unitl some one releases the resource, and my application gets unaccesible?
Any sugestions to solve the problem?
 
Rudy Dakota
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database? What kind of statement? Some elementary information might help in thinking up a solution.
Please try again,
Rudy.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34378
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Leandro,
I think you answered your own question. Usually this happens when another process has a lock on a table. Make sure to close all your statements/connections to avoid programs causing this error.
Sometimes the problem occurs when you are looking at a table using an interactive tool and the tool crashes. In this case, you have to restart the database.
 
Leandro Oliveira
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application creates many connectiosn/statements and closes all of them. The problem is that there are other workers working directly with our ORACLE database (with SQL NAVIGATOR). And these users some times don't commit their transactions, and the sistem gets itself down, not responding to requests which need data base access... All I wanted is a way to notify the application user that there is another user working with that data and, tell him to try later.
 
Rudy Dakota
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if that 's what you want, that is mostly information you can get from the system tables. How to go about that exactly , that 's another story. Highly product specific, and so.
So, once again: what RDBMS are you using?
Good riddance,
Rudy.
 
Dana Hanna
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could execute the quesry in a seperate Thread, and after a given amount of time, call the cancel() method on the statement object (the original Thread would have to have a reference to it. All in all it's simple, but not for a beginning JDBC or Thread programmer.
You's also want to make this a pattern in your development, and implement it in a generic way - so it's not a simple solution.
I think that the bigger problem is people having direct access to run these types of locking queries on the database!
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic