Error java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
-
Thursday, August 13, 2009 6:58 AM
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
All Replies
-
Friday, August 14, 2009 1:12 AMModerator
This error means you have more than one active result set on the same connection. To do this against SQL Server 2005 you need to have MARS (Multiple Active Result Set) turned on. I dont know if jdbc-odbc driver supports this property. SQL Server drivers do support this property. One thing you can do is consume the data in the pending result set before you issue the next command.
This posting is provided "AS IS" with no warranties, and confers no rights- Proposed As Answer by Pak-Ming CheungMicrosoft Employee, Editor Friday, August 14, 2009 2:09 AM
- Marked As Answer by vb.net_learner Friday, August 14, 2009 12:56 PM
-
Friday, August 14, 2009 2:09 AMAnswerer
Yes, as mentioned by Raj, you can try the new feature MARS to resolve your problem.
Please note that you are currently using an old driver - sqlsrv32, which does not support MARS. Please download and use the latest driver for SQL Server (SQL Server Native Client 10.0) at: http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
Although I am not experienced in jdbc, i think that jdbc does support MARS from some other customers' postings.
More information about MARS:
http://msdn.microsoft.com/en-us/library/ms345109(SQL.90).aspx
Thanks,
Ming.
WDAC Team, Microsoft.
Pak-Ming Cheung - MSFT- Proposed As Answer by Pak-Ming CheungMicrosoft Employee, Editor Friday, August 14, 2009 2:10 AM
- Marked As Answer by vb.net_learner Friday, August 14, 2009 12:57 PM
-
Tuesday, August 18, 2009 8:29 PMModeratorAlso, instead of the JDBC ODBC bridge, you can use pure type 4 JDBC driver released by Microsoft.
http://msdn.microsoft.com/en-us/data/aa937724.aspx
Mugunthan

