954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error is [Microsoft][ODBC SQL Server Driver]Connection is busy

Hi,

I hava 1 error in accessing database using javabean in jsp(jsp custom actions).The error like this

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt

my source code is given below.Anybody help me??

package SQLBean; 
import java.sql.*; 
import java.io.*; 
public class DbBean implements java.io.Serializable{ 
private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; 
private Connection dbCon; 
public DbBean(){ 
super(); 
} 

public boolean connect() throws ClassNotFoundException,SQLException{ 
Class.forName(dbDriver); 
dbCon = DriverManager.getConnection("jdbc  dbc:mybean","",""); 
return true; 
} 
public void close() throws SQLException{ 
dbCon.close(); 
} 
public ResultSet execSQL(String sql) throws SQLException{ 
Statement s = dbCon.createStatement(); 
ResultSet r = s.executeQuery(sql); 
return (r == null) ? null : r; 
} 
public int updateSQL(String sql) throws SQLException{ 
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r; 
} 
}
<HTML> 
<HEAD><TITLE>DataBase Search</TITLE></HEAD> 
<BODY> 

<%@ page language="Java" import="java.sql.*" %> 
<%@ page import="SQLBean.*"%> 

<jsp:useBean id="db" scope="application" class="SQLBean.DbBean" /> 

<jsp:setProperty name="db" property="*" /> 

<center> 
<h2> Results from </h2> 
<hr> 
 
<table> 

<% 
db.connect(); 
ResultSet rs = db.execSQL("select * from employ"); 
int i = db.updateSQL("UPDATE employ set fname = 'raji' where empno='000010'"); 
out.println(i); 

while(rs.next()) { 
%> 
<%= rs.getString("empno") %> 
<BR> 
<% 
} 
%> 
<BR> 
<% 
db.close(); 
%> 
Done 
</table> 
</body> 
</HTML>


Anyone help me??
Thanx in advance....

muthumari
Newbie Poster
20 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

I am not completely sure if I know the exact cause but I think SQL server supports only one statement per connection. So, if you want to exeucte another query, you will require a new connection. You might find some information on Microsoft's support page for the driver.

aniseed
Posting Whiz
359 posts since Apr 2006
Reputation Points: 48
Solved Threads: 7
 

hey try this custom object copy and paste to make your connection to mssql worthy, thanks

georgequinne
Newbie Poster
1 post since Feb 2010
Reputation Points: 8
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You