tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris McCluskey <ch...@netsolutionsllc.com>
Subject Jdbc-odbc bridge: app not closing MSSQL database connections
Date Tue, 16 Oct 2001 20:42:51 GMT
Hello, I am having a problem with my database connections not closing
with MSSQL and jakarta tomcat on a WIN-NT 4 box.  Here's a run down of
the damage:

---------------
page.jsp:

<jsp:useBean id="db" class="com.netsolutions.dataBase">

<% 
db.connect();
ResultSet rs = db.query("SELECT blah FROM foo");
while(rs.next()) {
  %>
  blah:  <%= rs.getString(1) %>
  <%
}

db.close();
%>

--------------
dataBase.java (snippet):

import java.sql.*;
import java.lang.Class;

public class dataBase {

  private Connection con;

  public void connect() {

    try {
      DriverManager.registerDriver(new
sun.jdbc.odbc.JdbcOdbcDriver());
    } catch (Exception e) {
      e.printStackTrace(System.out);
    }

    try {
      con = DriverManager.getConnection ("jdbc:odbc:mydsn","username",
"password");
    } catch (SQLException se) {
      System.out.println("SQL Exception: " + se.getMessage());
      se.printStackTrace(System.out);
    }

  }

  public void close() {
    try {
      con.close();
      // rs.close();
    } catch (SQLException se) {
      System.out.println("SQL Exception: " + se.getMessage());
      se.printStackTrace(System.out);
    }
  }

}

-------------
Keep in mind that I only posted the connect() and close() methods in
the dataBase class..

the problem that i'm having is everytime i would use page.jsp, the
database connection would open, i would get my ResultSet passed, but
afterwards, even when i run the close() method on the connection
varible the database connection is still open.. I think this is half
the server environment, and half my app..

any suggestions?

Thanks in advance!

-Chris


_________________________________________________ 
Chris McCluskey, Web Applications Engineer 
Net Solutions, LLC 
840 Lawrence Street 
Eugene, OR 97401 
chris@netsolutionsllc.com 
Voice +1 541 345-7087 
Fax +1 541 485-5519 
<http://www.netsolutionsllc.com> 
**************************************************
The contents of this transmission may be confidential in 
nature and should be directed only to the person to whom it 
is addressed. Do not read, copy, or disseminate this 
material unless you are the intended recipient. If this 
transmission reached you in error, please forward the e-mail 
to the sender to advise, then destroy the transmission you 
received. Thank you. 



Mime
View raw message