JDBC connect problem
If the connection failed, how can I know it is due to the username or password invalid? Because I want to seperate the processing logic for different error. such as
dbconn = DriverManager.getConnection(url,userid, password);
if(.....)
System.out.println("database username or password is incorrect.);
if (.....)
System.out.println("database driver is incorrect.);
[400 byte] By [
henry_22a] at [2007-11-27 4:44:30]

# 1
by default, the getConnection method should throw a SQLException whenever an error has occurred.. i don't know if there is a better way to do this, but i will suggest you to compare the exception's message (e.getMessage()) to differentiate the type of exception.
# 2
Hi,
Try using getErrorCode() method
try{}
catch(SQLException sqle)
{
int errornumber=sqle.getErrorCode();
}
suppose u get errornumber value as 1 for invalid unername and password....then
if(errornumber==1)
{
System.out.print("Invalid Username/password");
}
I m not sure what are the error codes for the diff error thrown...u need to check in command prompt what error code u got and then add respective error code value in ur if statements...
All the Best.