Barranger,

Try something like.

while(dataResultSet.next()){
        if (result.getString("Password").trim()){
                return true;
        }
        else return false;
}

Tom Kochanowicz


-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Barranger Ridler
Sent: Saturday, April 08, 2000 3:09 PM
To: [EMAIL PROTECTED]
Subject: Db connection crashes servlet server


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

___________________________________________________________________________
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