Hello,
I am having some strange trouble with a simple class that uses JDBC to
access mysql. Here is the error I receive:
SQLException: No suitable driver
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(Unknown Source)
Here is the code in my class:
try {
Class.forName("com.mysql.jdbc.Driver");
try {
Connection conn = DriverManager.getConnection(
"jdbc:mysql:TestDB");
I am using win2k pro, java 1.3.1, mysql 4.09gamma
I have used both of these jdbc drivers with the same result:
connector/j 2.0.14 and 3.0.4gamma
According to the readme that comes with the drivers, the problem is either a
bad database url or the driver isn't in my classpath. I do have it in my
class path. Here is the result of echo %CLASSPATH%:
c:\classes;C:\mysql-connector-java-2.0.14\mysql-connector-java-2.0.14-bin.ja
r;.;
As far as the database url that I pass to getConnection, the one above
actually worked on my machine two weeks ago but does not work today.
Following the hints in the readme, I tried these variations on the url:
"jdbc:mysql://TestDB"
"jdbc:mysql://localhost:3306/TestDB"
Also, even though I was getting a SQLException and not a
ClassNotFoundException, I changed the driver line of the code to:
Class.forName("com.mysql.jdbc.Driver").newInstance();
None of these worked. I hope someone is able to explain what simple thing I
am missing. Thank you very much for your help.
Steve Gere