none
Error java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt

    Question

  • Hello,

    my OS is windows XP
    i am using ms sql server 2005 express
    my java is jdk1.5.01_02
      

    my code is



    <html>
    <body>
    <form method="post" action="selection.jsp">
    <%@ page import="java.sql.*" %>
    <%
     String name = (String)session.getAttribute("name");
     String type = (String)session.getAttribute("type");
     out.println("<h3>");
     out.println(name);
     out.println("</h3>");
     out.println("<b>");
     out.println("  logged in as " + type + "<br>");
    %>
     <a href="login.html">logout</a>
    <%
     out.println("  ");
    %>
     <a href="ChangePassword.html">Change Password</a>
    <%

    try{
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection con = DriverManager.getConnection("jdbc:odbc:status");
     Statement st = con.createStatement();
     String query ="SELECT * FROM project where manager = '"+ name +"' ORDER BY projectid";
     ResultSet rs = st.executeQuery(query);
     int i = 1;
     
    %>
     <table border="1" bgcolor="yellow">
      <tr><h4>
       <td width="100"><h4>S._No</h4></td>
       <td><h4>Select</h4></td>
       <td width="400"><h4>Project_ID</h4></td>
       <td width="100"><h4>Task_ID</h4></td>
       <td align="center" width="200"><h4>Description_of_Task_Assigned_to_Executive</h4></td>
       <td width="100"><h4>Task_Priority</h4></td>
       <td width="120"><h4>Executive(employeeno)</h4></td>
       <td width="200"><h4>Manager(employeeno)</h4></td>
       <td width="200"><h4>Duration(days)</h4></td>
       <td width="200"><h4>Start Date</h4></td>
       <td width="200"><h4>End Date</h4></td>
       <td width="200"><h4>Actual Start Date</h4></td>
       <td width="200"><h4>Actual End Date</h4></td>
       <td><h4>Current_Status</h4></td>
       <td width="200"><h4>Employee_Remarks</h4></td>
       <td width="200"><h4>Manager_Remarks</h4></td>
      </h4></tr>
    <%
     
     while(rs.next())
     {
     Integer j = rs.getInt(1);
     out.println("<tr><td>");
     out.println(i);
     out.println("<td><input type=checkbox name=chkb value="+j+">");
     out.println("<td>");
     out.println(rs.getString(2));
     out.println("<td>");
     out.println(rs.getString(3));
     out.println("<td>");
     out.println(rs.getString(4));
     out.println("<td>");
     out.println(rs.getString(5));
     out.println("<td>");
     out.println(rs.getString(6));
     out.println("<td>");
     out.println(rs.getString(7));
     out.println("<td>");
     out.println(rs.getInt(8));
     out.println("<td>");
     out.println(rs.getDate(9));
     out.println("<td>");
     out.println(rs.getDate(10));
     out.println("<td>");
     out.println(rs.getDate(11));
     out.println("<td>");
     out.println(rs.getDate(12));
     out.println("<td>");
     out.println(rs.getString(13));
     out.println("<td>");
     out.println(rs.getString(14));
     out.println("<td>");
     out.println(rs.getString(15));
     out.println("</tr>");
     i++;
     }
     rs.close();
     st.close();
     con.close();
     }
     catch(Exception e)
     {
     out.println("Error1 " + e);
     }

    %>
     </table>
     
      <br>
      
      <select name="project" size="1">
      <%
      try{
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection con = DriverManager.getConnection("jdbc:odbc:status");
     Statement st = con.createStatement();
     String query ="SELECT projectid FROM projects ORDER BY projectid";
     ResultSet rs = st.executeQuery(query);
     while(rs.next()){
               String projectid = rs.getString(1);
               %>
               <option><%=projectid%></option>
              <%}
           rs.close();
      st.close();
      con.close();
              }
              catch(Exception e){
               out.println("Error " + e);
              }
              %>
              </select>
              <input type=submit name=submit value="Project Status">
         <input type="submit" name="submit" value="Add Task"><br>
              <%
     
     try{
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection con = DriverManager.getConnection("jdbc:odbc:status");
      Statement st = con.createStatement();
      String query = "SELECT firstname, lastname,employeeno FROM profile WHERE type = 'executive' ORDER BY firstname";
      ResultSet rs = st.executeQuery(query);
      %>
      <select name="employee" size="1">
      <%
      while(rs.next()){
       String fname = rs.getString(1);
       String lname = rs.getString(2);
       String employeeno = rs.getString(3);
       String fullname = fname + " " + lname +"("+ employeeno+")";
       %>
       <option><%=fullname%></option>
       <%
      }
      rs.close();
      st.close();
      con.close();
     }
     catch(Exception e)
     {
      out.println("Error " + e);
     }
    %>
      
      <input type="submit" name="submit" value="Employee Status">
      <input type="submit" name="submit" value="Employee Profile"><br>
      
      
      <input type="submit" name="submit" value="Sort By">
      <select size="1" name="datetype"><option>startdate<option>enddate</select><br>
      <input type="submit" name="submit" value="Comment"><br>
      <input type=submit name=submit value="Delete Row">
      
      
     
    </form>
    </body>
    </html>






    i am getting error:

    Error java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt


    please help
    I tried my best for all available resources.

    Ajay Kumar

    Thursday, August 13, 2009 6:58 AM

Answers

All replies