tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shravan Shashikant <s0s7...@unix.tamu.edu>
Subject Re: JDBC ODBC crashes tomcat
Date Wed, 20 Sep 2000 18:29:48 GMT
Hi John,
  Yeah,I used to face the same problem.I can give u some suggestions as to
how to solve this.
  Try inserting this into your code.
  before execute query statement set rs=null and call System.gc();Then
execute query.
Check it out.
Shravan


On Wed, 20 Sep 2000 John_Ewing@keybank.com wrote:

> 
> I am trying to det up a simple web app that interacts with a ms access db.  Any
> time I interact with the database tomcat (not immediately) shuts down.
> For instance, I have a static html page which sends a userid and password to a
> servlet, the servlet calls a login controller class, which calls a userObject
> class which opens the database, userObject class sends the results back to the
> logincontroller class, which checks the password and sends the results back to
> the servlet. the servlet then rd.forwards the corresponding .jsp file.  The app
> always crashes on the forward, but if I exclude the database stuff It works
> fine.  Has anyone experienced this before?  If you need more code I will post
> it.
> 
> John
> 
> DB Code:
> 
>   //---------------------------------------
>   // Authenticate the User
>   //---------------------------------------
>   private boolean authUser(){
>     openDB();
>     try {
>       if (mConnection != null){ //we have a connection
>         select = mConnection.createStatement();
>         rs = select.executeQuery("SELECT userPass FROM keylinkUserAuth WHERE
> userSSN = '" + logonID.trim() + "'");
>         rs.next();
>         if(password.equals(rs.getString("userPass"))){
>           closeDB();
>           return true;
>           }
>        }
>     }catch (SQLException sqle) {
>        System.err.println(sqle.getMessage());
>        }
>     closeDB();
>     return false;
> }
> 
> 
>   //---------------------------------------
>   // Open the Database
>   //---------------------------------------
>   public void openDB(){
>     try{
>       //System.out.println("Trying to open Database...");
>       DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
>       mConnection = DriverManager.getConnection("jdbc:odbc:keylink","","");
>       //System.out.println("Database opened");
>       }
>     catch(SQLException e){("Database
>       System.err.println("SQL Exception, unable to load driver.");
>       e.printStackTrace();
>       }
>     catch(Exception e){();SQL
>       System.err.println("Exception, unable to load driver.");
>       e.printStackTrace();
>     }
>   }// end openDB()
> 
>   //---------------------------------------
>   // Close the Database
>   //---------------------------------------
>   public void closeDB(){
>     try{
>       mConnection.commit();
>       mConnection.close();
>       //System.out.println("Database closed");
>       }
> 
>     catch(SQLException e){("Database
>       System.err.println("SQL Exception, unable to close database connection.");
>       e.printStackTrace();
>       }
>     catch(Exception e){();SQL
>       System.err.println("Exception, unable to close database connection.");
>       e.printStackTrace();
>     }
>   }// end closeDB()
> 
> 


Mime
View raw message