Results 1 to 9 of 9
  1. #1
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default MySQL: No suitable driver found.

    Hello,

    I want to establish a connection to my MySQL database so I can query it from my jsp/web application. I added mysql-connector-java-5.1.14-bin.jar to my WEB-INF/lib folder.

    Now when I try to establish a connection it says: No suitable driver found for jdbc:mysql://localhost?autoReconnect=true.

    The lines in my code where the error occurs are:

    Java Code:
                m_url = "jdbc:mysql://" + mDatabaseHost +"?autoReconnect=true";
                m_connection = DriverManager.getConnection(m_url, mDatabaseUser, mDatabasePassword);
    User and password are correct. What might be wrong?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: MySQL: No suitable driver found.

    Have you loaded the driver?
    Java Code:
    Class.forName("com.mysql.jdbc.Driver"); // check the class name

  3. #3
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default Re: MySQL: No suitable driver found.

    This yields a ClassNotFoundException.

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: MySQL: No suitable driver found.

    You need to add the library to your classpath.

  5. #5
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default Re: MySQL: No suitable driver found.

    And how do I do that?

    I thought when adding a library to WEB-INF/lib it is automatically added?

  6. #6
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: MySQL: No suitable driver found.

    Quote Originally Posted by Onra View Post
    I thought when adding a library to WEB-INF/lib it is automatically added?
    Given the error, it is evidently not. Make sure when you deploy it is contained within as you expect, or consult the manual/instructions for the software (and version) you are using to verify this folder is placed on the classpath and/or the best place to add libraries to the classpath of the container.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: MySQL: No suitable driver found.

    What server are you using?
    It does seem odd that it's not picking it up if everything is where it should be.

  8. #8
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default Re: MySQL: No suitable driver found.

    Tomcat 7.0.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: MySQL: No suitable driver found.

    Not used 7.
    I'd be surprised if they'd changed the basic structure of what a web app should look like.

Similar Threads

  1. No suitable driver found
    By chinna in forum New To Java
    Replies: 3
    Last Post: 11-30-2011, 01:17 PM
  2. Replies: 6
    Last Post: 09-01-2010, 11:29 AM
  3. No suitable driver found exception error
    By Crazy Caveman in forum Networking
    Replies: 1
    Last Post: 09-01-2010, 12:03 AM
  4. No suitable driver found
    By geekchick in forum New To Java
    Replies: 2
    Last Post: 08-25-2010, 12:12 AM
  5. Replies: 13
    Last Post: 03-16-2009, 09:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •