• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Connection is busy with results for another hstmt

 
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
 
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;;;;
}
 
author & internet detective
Posts: 40200
816
Eclipse IDE VI Editor Java
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic