esluye
December 21st, 2002, 10:50 AM
hi,
i already success buil the connection with my user info. but the peoblem is, when i enter the correct user name and the wrong password, it's still work. Below is the coding for the validate username and password that had benn done, please check for me what's wrong with the coding. Thanks.
-----------------------------------------------------------------------------------
void jButton1_actionPerformed(ActionEvent e) {
String userid = jTextField1.getText();
System.out.println( "User ID is : " + userid);
try
{
connection = getDBConnection();
String query = "SELECT * FROM UserInfo WHERE UserID='" + userid + "'";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery( query );
//displayResultSet ( resultSet );
resultSet.next();
String dbUserID = resultSet.getString("UserID");
if (dbUserID != null)
{
String dbUserPasswd = resultSet.getString("Password");
/* if(passwd equals with db password or not)
call to DataMining page
else
invalid password*/
System.out.println("dbUserID: " + dbUserID);
System.out.println("dbUserPasswd: " + dbUserPasswd);
}
else
{
System.out.println("dbUserID is null");
}
statement.close();
connection.close();
}
catch(SQLException sqlex)
{
System.out.println("DB Connection failed: " + sqlex);
//throw new SQLException("DB Connection failed");
}
:( :confused:
i already success buil the connection with my user info. but the peoblem is, when i enter the correct user name and the wrong password, it's still work. Below is the coding for the validate username and password that had benn done, please check for me what's wrong with the coding. Thanks.
-----------------------------------------------------------------------------------
void jButton1_actionPerformed(ActionEvent e) {
String userid = jTextField1.getText();
System.out.println( "User ID is : " + userid);
try
{
connection = getDBConnection();
String query = "SELECT * FROM UserInfo WHERE UserID='" + userid + "'";
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery( query );
//displayResultSet ( resultSet );
resultSet.next();
String dbUserID = resultSet.getString("UserID");
if (dbUserID != null)
{
String dbUserPasswd = resultSet.getString("Password");
/* if(passwd equals with db password or not)
call to DataMining page
else
invalid password*/
System.out.println("dbUserID: " + dbUserID);
System.out.println("dbUserPasswd: " + dbUserPasswd);
}
else
{
System.out.println("dbUserID is null");
}
statement.close();
connection.close();
}
catch(SQLException sqlex)
{
System.out.println("DB Connection failed: " + sqlex);
//throw new SQLException("DB Connection failed");
}
:( :confused: