Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection is busy with results for another hstmt

 
mat mat
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i am using tomcat 4.12 and sql server 2000 in our project. i am getting Connection is busy with results for another hstmt exception. i am executing second query based on the first query result. once first query is executed then i had closed resultset and statement objects and reused result set and statement object n the second query. so i am doing same continuosuly.

My code:
boolean ff=false;
int i=0;
st= conn.createStatement();
rs=st.executeQuery("select name from emp");
while(rs.next())
{
i++;
}
if(i>0) ff=true;

if(!ff)
{
if(rs!=null){ rs.close(); rs=null; }
if(st!=null) { st.close(); st=null; }
st= conn.createStatement();
rs=st.executeQuery("select name from emp");
while(rs.next())
{
i++;
}
if(i>0) ff=true;
}

if(!ff)
{

code continues;;;;
}


what should i do

Thanks
 
pankaj patil
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this

boolean ff=false;
int i=0;
st= conn.createStatement();
rs=st.executeQuery("select name from emp");
while(rs.next())
{
i++;
}
if(i>0) ff=true;

if(!ff)
{
rs=st.executeQuery("select name from emp");
while(rs.next())
{
i++;
}
if(i>0) ff=true;
}

if(!ff)
{

code continues;;;;
}
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Mat mat",
Welcome to JavaRanch!

We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Please pick a last name that is different from your first name.

Thanks,
Jeanne
JDBC Forum Bartender
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic