943,733 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 10687
  • JSP RSS
May 8th, 2006
0

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

Expand Post »
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??


java Syntax (Toggle Plain Text)
  1. package SQLBean;
  2. import java.sql.*;
  3. import java.io.*;
  4. public class DbBean implements java.io.Serializable{
  5. private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
  6. private Connection dbCon;
  7. public DbBean(){
  8. super();
  9. }
  10.  
  11. public boolean connect() throws ClassNotFoundException,SQLException{
  12. Class.forName(dbDriver);
  13. dbCon = DriverManager.getConnection("jdbc dbc:mybean","","");
  14. return true;
  15. }
  16. public void close() throws SQLException{
  17. dbCon.close();
  18. }
  19. public ResultSet execSQL(String sql) throws SQLException{
  20. Statement s = dbCon.createStatement();
  21. ResultSet r = s.executeQuery(sql);
  22. return (r == null) ? null : r;
  23. }
  24. public int updateSQL(String sql) throws SQLException{
  25. Statement s = dbCon.createStatement();
  26. int r = s.executeUpdate(sql);
  27. return (r == 0) ? 0 : r;
  28. }
  29. }


JSP Syntax (Toggle Plain Text)
  1. <HTML>
  2. <HEAD><TITLE>DataBase Search</TITLE></HEAD>
  3. <BODY>
  4.  
  5. <%@ page language="Java" import="java.sql.*" %>
  6. <%@ page import="SQLBean.*"%>
  7.  
  8. <jsp:useBean id="db" scope="application" class="SQLBean.DbBean" />
  9.  
  10. <jsp:setProperty name="db" property="*" />
  11.  
  12. <center>
  13. <h2> Results from </h2>
  14. <hr>
  15. <br><br>
  16. <table>
  17.  
  18. <%
  19. db.connect();
  20. ResultSet rs = db.execSQL("select * from employ");
  21. int i = db.updateSQL("UPDATE employ set fname = 'raji' where empno='000010'");
  22. out.println(i);
  23.  
  24. while(rs.next()) {
  25. %>
  26. <%= rs.getString("empno") %>
  27. <BR>
  28. <%
  29. }
  30. %>
  31. <BR>
  32. <%
  33. db.close();
  34. %>
  35. Done
  36. </table>
  37. </body>
  38. </HTML>

Anyone help me??
Thanx in advance....
Last edited by peter_budo; Feb 8th, 2010 at 3:22 am. Reason: Just adding tags
Reputation Points: 10
Solved Threads: 0
Newbie Poster
muthumari is offline Offline
20 posts
since Mar 2006
May 8th, 2006
0

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

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.
Reputation Points: 48
Solved Threads: 7
Posting Whiz
aniseed is offline Offline
353 posts
since Apr 2006
Feb 7th, 2010
-1

odbc_connection string cross scripting in object

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

<URL SNIPPED>
Last edited by peter_budo; Feb 8th, 2010 at 3:23 am. Reason: Keep It On The Site - Posts must contain actual content and substance and cannot simply be external links.
Reputation Points: 8
Solved Threads: 0
Newbie Poster
georgequinne is offline Offline
1 posts
since Feb 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: How to Manipulate Script Calender
Next Thread in JSP Forum Timeline: Jsf Login Component





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC