File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Error is [Microsoft][ODBC SQL Server Driver]Connection is busy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Error is [Microsoft][ODBC SQL Server Driver]Connection is busy " Watch "Error is [Microsoft][ODBC SQL Server Driver]Connection is busy " New topic

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

raji navaneethan

Joined: Apr 06, 2006
Posts: 15

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.*;
public class DbBean implements{
private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private Connection dbCon;
public DbBean(){

public boolean connect() throws ClassNotFoundException,SQLException{
dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
return true;
public void close() throws SQLException{
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;

<HEAD><TITLE>DataBase Search</TITLE></HEAD>

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

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

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

<h2> Results from </h2>

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

while( {
<%= rs.getString("empno") %>

Anyone help me??
Thanx in advance....
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63548

Moved to the JDBC forum.

[Asking smart questions] [About Bear] [Books by Bear]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32819

It looks like two threads are executing the JSP simultaneousy. Try making the connection a local variable instead of an instance variable.

Note that it would be preferable to have the JDBC/Java code in a class rather than the JSP. It is better design and more maintainable.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Error is [Microsoft][ODBC SQL Server Driver]Connection is busy
It's not a secret anymore!