you must close your resultset when you are finished with it.  add a line
right before you return that reads:  result.close();

bradley mclain

>From: Barranger Ridler <[EMAIL PROTECTED]>
>Reply-To: "A mailing list for discussion about Sun Microsystem's Java
>        Servlet API Technology." <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Db connection crashes servlet server
>Date: Sat, 8 Apr 2000 16:09:07 -0400
>
>Hello there,
>
>         I have a simple servlet that connects to an access database to
>check the
>name and password of a user.  While it does check this correctly, the
>server
>will crash a few minutes later (Possibly when the distroy() method is
>called?? which has no code).  Anyways any help would definately help.
>Here's the code that is used to connect.  Sorry about the length
>
>Barranger
>
>         /**
>          * Check the User Name and Password
>          */
>         public boolean login(String name, String pwd)
>         {
>                 //Set the Variables to connect to the Database
>                 String URL = "jdbc:odbc:Mail";
>         String username = "";
>         String password = "";
>
>                 //Try to load the appropriate Driver
>         try
>                 {
>                         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>         }
>                 catch (Exception e)
>                 {
>             return false;
>         }
>
>                 //Declare the Objects
>         Statement  stmt = null;
>         Connection con  = null;
>
>                 //Create the Objects
>         try
>                 {
>             con = DriverManager.getConnection (URL, username, password);
>             stmt = con.createStatement();
>         }
>                 catch (Exception e)
>                 {
>                         return false;
>         }
>
>                 //Declare and Create the ResultSet object
>                 try
>                 {
>             ResultSet result = stmt.executeQuery
>                                 (
>                                         "SELECT * FROM user WHERE
>user_name = '" + name +
>                                         "' AND user_password = '" + pwd +
>"';"
>                                 );
>
>                         //If there are any records then the user exists
>                         if(result.next())
>                         {
>                                 return true;
>                         }
>                         else
>                         {
>                                 return false;
>                         }
>                 }
>                 catch (Exception e)
>                 {
>                         return false;
>                 }
>         }
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to