"[ODBC Sql Server Driver]Connection is busy with results !_NEWLINE_!from another hstmt" ERROR: when attempt to DROP OR !_NEWLINE_!INSERT after INSERT.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   David_Saintloth
Posted On:   Monday, April 29, 2002 10:19 PM

I am writing an application that will self build tables on Sql 2000. I am able to connect and create and drop tables but when I try inserting data and then dropping the table afterward I get the error listed above. What am I doing wrong? I found that when I do a TRUNCATE before attempting to DROP, it works but **only** from a SQL Query Tool window and NOT through a JDBC call from the app. for the exact same TRUNCATE command. I also get the same error when trying to INSERT after INSERT from the app. which makes using the dbase entirely useless since I'll need to do multiple INSERTS,UPDATES AND DELETES. As before, the same INSERT works perfectly from the Sql Query    More>>

I am writing an application that will self build tables on Sql 2000.
I am able to connect and create and drop
tables but when I try inserting data and then dropping
the table afterward I get the error listed
above. What am I doing wrong? I found that when I do a
TRUNCATE before attempting to DROP, it works but
**only** from a SQL Query Tool window and NOT through
a JDBC call from the app. for the exact same TRUNCATE
command. I also get the same error

when trying to INSERT after INSERT from the app. which
makes using the dbase entirely useless since I'll need to
do multiple INSERTS,UPDATES AND DELETES. As before,
the same INSERT works perfectly from the Sql Query
Tool Window however.






Any Idea why this is happening? I tried doing an
explicit "commit" following each attempt and that doesn't
work. There is something wierd going on here, surely
someone has figured out how to do consecutive
INSERTS,UPDATES AND DELETES via JDBC and connecting to MS
SQL 2000 ??? I am using the jdbcodbc bridge driver if
that helps any.




Any help provided would be much appreciated.

Regards,
Dsl

   <<Less

Re: "[ODBC Sql Server Driver]Connection is busy with results !_NEWLINE_!from another hstmt" ERROR: when attempt to DROP OR !_NEWLINE_!INSERT after INSERT.

Posted By:   David_Saintloth  
Posted On:   Wednesday, May 1, 2002 01:18 PM

I figured it out myself.


I figured out what the problem was and it did have to do

with improperly closed requests, but not connection requests the


problem centered around the fact that in my DBconnection class I


created a boolean method called "executeTableTest(string tabname)"


that I basically run a simple SELECT statement on a table passed in as


argument "tabname". For SELECT statements the
connection.executeQuery() method is used and is first

passed to a


statement object, the results of the statement are passed to a


resultset object. It turns out that I wasn't closing my result set


object after executing the table test. This held up the hstmt and when


the next request occured I would get the error message. After ensuring


the resultset is closed after every statement execution I was able to


freely CREATE, INSERT and DROP tables with aplomb.







****If you are having similar issues with MS Sql Server, most likely
the error is a side affect of your code causing a conflicting htsmt
error.****







Note the error only occured when the same connection has a second


statement executed on it, while a previously run statement on that


same connection still has an open resultset. Caution should be taken


to either

efficiently close the result set(ideal) or open and close
new connections for each statement execution. (which is

costly and not


recommended)







I know I answered my own question, but if this can help

someone else
avoid the headaches I went through for the last 4 days it's worth it.



Regards,


Dsl
About | Sitemap | Contact