Results 1 to 9 of 9
Thread: MySQL: No suitable driver found.
- 12-14-2011, 05:15 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
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:
User and password are correct. What might be wrong?Java Code:m_url = "jdbc:mysql://" + mDatabaseHost +"?autoReconnect=true"; m_connection = DriverManager.getConnection(m_url, mDatabaseUser, mDatabasePassword);
- 12-14-2011, 06:12 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: MySQL: No suitable driver found.
Have you loaded the driver?
Java Code:Class.forName("com.mysql.jdbc.Driver"); // check the class name
- 12-14-2011, 07:15 PM #3
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
Re: MySQL: No suitable driver found.
This yields a ClassNotFoundException.
- 12-14-2011, 07:23 PM #4
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: MySQL: No suitable driver found.
You need to add the library to your classpath.
- 12-14-2011, 08:08 PM #5
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
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?
- 12-14-2011, 09:51 PM #6
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: MySQL: No suitable driver found.
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.
- 12-15-2011, 09:22 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
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.
- 12-15-2011, 01:51 PM #8
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
Re: MySQL: No suitable driver found.
Tomcat 7.0.
- 12-15-2011, 02:41 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
No suitable driver found
By chinna in forum New To JavaReplies: 3Last Post: 11-30-2011, 01:17 PM -
java.sql.SQLException: No suitable driver
By Heather in forum JDBCReplies: 6Last Post: 09-01-2010, 11:29 AM -
No suitable driver found exception error
By Crazy Caveman in forum NetworkingReplies: 1Last Post: 09-01-2010, 12:03 AM -
No suitable driver found
By geekchick in forum New To JavaReplies: 2Last Post: 08-25-2010, 12:12 AM -
java.sql.SQLException: No suitable driver .... when using Custom ClassLoader
By tomer1960 in forum Advanced JavaReplies: 13Last Post: 03-16-2009, 09:37 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks