Link to home
Start Free TrialLog in
Avatar of Rrugemalira
Rrugemalira

asked on

JDBC: SQLException: No suitable driver; SQLState: 08001 VendorError: 0

SQLException: No suitable driver
SQLState: 08001
VendorError: 0

1. I have /usr/local/mysql-connector-java-3.1.6/mysql-connector-java-3.1.6-bin.jar
2. The userconfig.sh file is in /usr/local/j2sdkee1.3.1/bin
3. userconfig.sh contains these lines:

J2EE_CLASSPATH=/usr/local/mysql-connector-java-3.1.6/com/mysql/jdbc:/usr/local/mysql-connector-java-3.1.6/mysql-connector-java-3.1.6-bin.jar
export J2EE_CLASSPATH

JAVA_HOME="/opt/j2sdk1.4.2_04
export JAVA_HOME

4. The culprit code segment is as follows:
   Connection conn = DriverManager.getConnection(
           "jdbc:/usr/local/mysql/bin://localhost/rtpmKenyaDB","rrugemalira", "Nahum7");

How do I solve this?  Kindly instruct.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

copy the jar to <webapp>/WEB-INF/lib
>            "jdbc:/usr/local/mysql/bin://localhost/rtpmKenyaDB","rrugemalira", "Nahum7");

and change connect string to:

           "jdbc:mysql://localhost/rtpmKenyaDB","rrugemalira", "Nahum7");
Avatar of Rrugemalira
Rrugemalira

ASKER

I do have mysql-connector-java-3.1.6-bin.jar  in WEB-INF/lib
did u change the connect string?
I've also changed "jdbc:/usr/local/mysql/bin://localhost/rtpmKenyaDB","rrugemalira", "Nahum7");
to "jdbc:mysql://localhost/rtpmKenyaDB","rrugemalira", "Nahum7");

AND NOW THE ERROR READS:
SQLException: Access denied for user 'rrugemalira'@'localhost.localdomain' (using password: YES)
SQLState: 28000
VendorError: 1045
Looks like you don't have rights to login with that user/password
check the mysql logins.

Have you loaded the driver via the classloader?

e.g.
 try{
      Class.forName( driver ) ;//here
Connection conn = DriverManager.getConnection(
           "jdbc:/usr/local/mysql/bin://localhost/rtpmKenyaDB","rrugemalira", "Nahum7");
    stmt = conn.getStatement(..........);

    }catch (Exception e){
      System.out.print("Whoops, buggered") ;
    }
I will summarize:

1. I'm still stuck with the following error:
      SQLException: No suitable driver
      SQLState: 08001
      VendorError: 0

2. Is this userconfig.sh file correct? It resides in /usr/local/j2sdkee1.3.1/bin

export CLASSPATH="$CLASSPATH:/usr/local/mysql-connector-java-3.1.6/com/mysql/jdbc:/usr/local/mysql-connector-java-3.1.6/mysql-connector-java-3.1.6-bin.jar"

JAVA_HOME="/opt/j2sdk1.4.2_04"
export JAVA_HOME

3. I do have the file mysql-connector-java-3.1.6-bin.jar in the WEB-INF/lib directory

4. Here is the culprit code:

      try {
          // Create a session
          HttpSession session = request.getSession(true);
          // Load the JDBC driver
          Class.forName("com.mysql.jdbc.Driver");
          Connection conn = DriverManager.getConnection(
          "jdbc:/usr/local/mysql/bin://localhost/rtpmKenyaDB","rrugemalira", "NahumCh7");

I greatly appreciate your kind instruction.
Try default  port 3306

         Connection conn = DriverManager.getConnection(
          "jdbc:mysql://localhost:3306/rtpmKenyaDB","rrugemalira", "NahumCh7");
CASE 1
With the proposed fix:
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/rtpmKenyaDB","rrugemalira", "NahumCh7");
I get the following errors:
SQLException: Access denied for user 'rrugemalira'@'localhost.localdomain' (using password: YES)
SQLState: 28000
VendorError: 1045

CASE 2
With the following code:
Connection conn = DriverManager.getConnection(
"jdbc:/usr/local/mysql/bin://localhost:3306/rtpmKenyaDB","rrugemalira", "NahumCh7");
I get the following errors:
SQLException: No suitable driver
SQLState: 08001
VendorError: 0

What a vicious circle!

Q1. Does CASE 1 indicate a suitable driver is found but the access is denied?
Q2. Does CASE 2 indicate I have access but no suitable driver?

Q3. Is my userconfig.sh correct?

I'd appreciate any answers to the above questions.
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> Try giving access permisssions to 'rrugemalira'@'localhost.localdomain' using GRANT option in MySQL

I already suggested basically that, plus stated the other problems in your code
In my frustration, I understood ( caught on to) "Try giving access permissions to 'rrugemalira@localhost.localdomain' using GRANT option in MySQL" - from bloodredsun
than "check the mysql logins" - from objects.
Indee, in hind sight, objects gave me the solution much earlier but, I did not catch on to it!  Is it possible to share the points fifty fifty?
I do thank all of you for the kind instruction.
I'm happy with whatever Rrugemalira decides, be it 50-50 reassign or status quo...