User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 391,615 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,627 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 6662 | Replies: 1
Reply
Join Date: Mar 2006
Posts: 20
Reputation: muthumari is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
muthumari muthumari is offline Offline
Newbie Poster

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

  #1  
May 8th, 2006
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>
<br><br>
<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....
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2006
Location: Mumbai, India
Posts: 351
Reputation: aniseed is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 4
aniseed's Avatar
aniseed aniseed is offline Offline
Posting Whiz

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

  #2  
May 8th, 2006
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JSP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 12:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC