aspose file tools*
The moose likes JDBC and the fly likes [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt" Watch "[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt" New topic
Author

[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt

Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
Hey guys,

This would be my first time using JDBC within an application. The problem i am having now is the exception that is in the subject line.

Don't get me wrong now, I understand what it means, but i'm not sure what i am doing wrong.
So the database im querying is a little bit strange(at least i think i have yet to see any other database than this one).
Essentially i start off with one value, and must match that to a value in another table, to which i must take another value(being text or date) and compare that to another table. So, in this giant mess of connections and statements i get this error. I ended up creating a new connection for each separate query, but im concerned because i call another query(with a different Connection) before i finish my first query if that is screwing things up.

I am sorry if this does not make the most amount of sense, i am trying my hardest to make it clear.
I could post some code, but I would be a little embarrassed as i am sure that the JDBC handling seems infantile because this is not something that they teach us in school. I have a slight google-education in the matter right now.

I appreciate your help and suggestions in advance, if there is anything that i can clear up, please just let me know.
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Hi Joe,

I suppose you are executing queries while iterating in one result set. Can your sql statements and conditions be joined into one sql statement?
Opening a new connection will resolve your problems I guess. But i am pretty sure that some sql improvements can be done.

And there is nothing to be embarrassed or be sorry of since we are here to learn and share.

Regards,
Fatih.
Joe Meany
Greenhorn

Joined: Jun 14, 2011
Posts: 25
Yes that is exactly what i meant, in a much more elegant way

And I'm sure there are improvements to be made, but as a last ditch effort to fix my own problem i did open up a new connection for each of my result sets(i think it turns out to be 7 of them . And i still get the exception after doing that.

That is what really confuses me the most about this i guess.

And I am getting a result set sorting through it and if a condition is met, calling another method where there is more sorting of new result sets and another condition that again, if true, calls a third method that does the same except prints a date as opposed to call a method. If you think it would help the situation i can post the snippet of code in which i am having the problem, but i think ill clean it up a bit before i do that, just let me know if that would help at all.

Thanks very much for your quick reply!
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Connection is busy with results for another hstmt hit the google and found, this happens because an ODBC connection can only have one active cursor at a time.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt