aspose file tools*
The moose likes JDBC and the fly likes SQL Exception  Connection is busy with results for another hstmt. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Exception  Connection is busy with results for another hstmt." Watch "SQL Exception  Connection is busy with results for another hstmt." New topic
Author

SQL Exception Connection is busy with results for another hstmt.

Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Hi Ranchers

I am running a Java application which has multiple sql queries including update and insert.Basically I am connecting to a MS Sql Server.


But I am getting the following error.

Error Details - [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt.

I am getting this error only when my Jave application is accessing the database to do this update/insert. At the same time when
another application is updating the same database.

Please let me know if I need to post my piece of code which has the JDBC operations or this error is due to the database contention when two apps working on the same table.

Can you please let me know a work around for this kind of sql exception.


Thanks in advance
Bhazee
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30780
    
157

Prem,
Are you using different connection objects for the concurrent queries?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Yes,
I am using different connection objects for the concurrent queries and I am also closing both the connection objects.

Bhazee
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

can your share your snippet of code (which has JDBC Operation).


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Hi,
First of all thanks for your time. Here is the JDBC snippet.


Please let me know if you need more details.
Thanks
Bhazee
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

try to commit your first connection object before creating another one.

think it works. (not sure)
Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Hi
But I need to commit only when all the queries are executed successfully or else rollback both.

Thanks
Bhazee
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

what if? if you use the same connection Object for this transaction.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by Prem Bhazee:
Yes,
I am using different connection objects for the concurrent queries and I am also closing both the connection objects.

Bhazee


Are you sure?
You call getConnection(), but where do you check that it returns two different instances?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL Exception Connection is busy with results for another hstmt.