Hi
I am facing a frustrating problem here.
I am having a login screen. When users enter username and pwd they are
validated against a database (mysql). Everything is working perfectly.
but some times users get a null pointer exception when they are logging in.
I suspect that the connection object being returned is null sometimes.
but why is it occuring only some times ? other times eeverything is working
fine.
I am using a class to connect to the db.
Please read the code for the class belwo
*******************************************
import java.sql.*;
public class DBConnector{
public Connection conn;
public Connection connect() throws java.sql.SQLException{
try{
Class.forName("org.gjt.mm.mysql.Driver");
conn=DriverManager.getConnection("jdbc:mysql://192.168.0.4/WEBDB","test","tes
t");
}catch(Exception e){
System.out.println(e.toString());
}finally{
return conn;
}
}
}
*****************************************
In my login validation jsp page I use this line of code to connect to the db
DBConnector dbc=new DBConnector();
conn=dbc.connect();
SQL="select UserCode from t_users where Password=password(?)";
pstmt=conn.prepareStatement(SQL);
approximatley 200 users access my web application.
Can you please explain whats wrong in my approach? Its kinda critical to me.
Any help wud be invaluable
Thanx in advance
Deepak
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com