connection is busy with results for another stmt
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, November 5, 2001 12:50 AM

can anyone tell me why this problem is comming here is the code which is giving problem firstfunction Statement st1=con.createStatement() ResultSet rs1=st1.executeQuery(sql) while(rs1.next()) { //calling second function } secondfunction Statement st2=con.createStatement(); ResultSet rs2=st2.executeQuery(sql); while(rs2.next()) { //dosome thing here } when i am running the above i'm getting a run time error saying "connection is busy with results for another stmt" how can i solve the problem thank   More>>

can anyone tell me why this problem is comming


here is the code which is giving problem


firstfunction

Statement st1=con.createStatement()

ResultSet rs1=st1.executeQuery(sql)

while(rs1.next())

{

//calling second function

}


secondfunction

Statement st2=con.createStatement();

ResultSet rs2=st2.executeQuery(sql);

while(rs2.next())

{

//dosome thing here

}


when i am running the above i'm getting a run time error saying "connection is busy with results for another stmt"


how can i solve the problem


thanks in advance

aravind

   <<Less

Re: connection is busy with results for another stmt

Posted By:   Anonymous  
Posted On:   Wednesday, November 7, 2001 12:33 PM

Please read the FAQ:

Is Connection thread safe for Oracle drivers?


When I create multiple Statements on my Connection, only the current Statement appears to be executed. What's the problem?


This took less than five minutes, although I spent considerably more time answering and formatting the answer.

Re: connection is busy with results for another stmt

Posted By:   Bozidar_Dangubic  
Posted On:   Monday, November 5, 2001 05:58 AM

you cannot execute two statements on a single connection. function 1 executes st1 statement on conn. function 2 tries to execute st2 on the same connection. but this is not possible. you need to create another connection in function 2 to execute st2. a single connection can work on only a single statement at one time. if you want to execute another statement, you have to close the first statement. so, to fix the problem, create another connection - conn2 - in function 2 and create st2 from conn2 (e.g. Statement st2 = con2.createStatement(...);).
About | Sitemap | Contact