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