• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Process hangs in JDBC.

 
Sudhin Moorkoth
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a process that reads data from a table and update 2 tables and insert into 2 tables. I am using PreparedStatement and JDBC 2.0 in UDB database. My problem is once in a while my process hangs in ResultSet close statement. Sometimes it locks the table or database and no one can access the tables. If I close my process everybody is able to access data. This does not happen all the time and process hangs at different places in the code. I am using VA Java.
Has anyone face the same problem? Please let me know.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you handling transactions?
The only time I've had similar behaviour was in Oracle. If a transaction (via the SQLPlus DB client) wasn't being committed (explicitly), it also caused the Java app to hang.
A quick solution might be to use Connection.setAutoCommit(true) and see if it fixes things. Then you should remove it and go back and make sure you always rollback or commit all transactions...
or your problem might be something completely different...
DOM
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sudhin",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave
 
Sudhin Moorkoth
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
I have not explicitly mentioned autoCommit to true thinking that it is the default. I want to commit after each update or add. But in one place where I need to make sure that a new record is added in two tables and one table is updated and a record is deleted from another table as one transaction. For that I have code like this.
Conn.setAutoCommit(false);

I will change the code to add autocommit to true soon after the connection to database is established.
I have updated my profile to include my last name.
Sudhin
[ Edited by Dave to format code ]
[ February 24, 2002: Message edited by: David O'Meara ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic