HI, I'm working on a windows 7 laptop in an Eclipse Juno IDE writing a simple Java SE 7 Swing application to learn how to connect to my 5.5 MySQL database using a Connector/j driver.
I seem to be having trouble with java finding the Connector/j Driver.
I'm getting the following error message: "No suitable driver found for jdbc:mysql:3306//localhost/test".
I've made sure the mysql-connector-java-5.1.22-bin.jar file is in the classpath on my laptop as well as in the Eclipse IDE, but I still have this error.
Could you point me in the right dirrection?
Keep in mind this not for a webserver, just a stand alone Java swing application.
Here's a sample of my connection code:
Any advice at this point would be greatly appreciated.
In Eclipse, you can add various libraries to your project in Build Path panel. In Package explorer right click on your project's name, Buildpath->Configure Build Path->Libraries->Add external jars. Point this to driver's .jar file.
Joined: Mar 05, 2012
Hi Mark, thanks for the advice, but already did this using eclipse and still getting the same error. :-(
Here's what I've done so far:
1.) installed java SDK 7
2.) installed Connector/j 5.1
3.) installed Eclipse Juno IDE
4.) installed TextPad IDE //to eliminate issue being with Eclipse
5.) added Connector/j to laptop classpath: C:\java mysql driver\mysql-connector-java-5.1.22-bin.jar
6.) Configured Eclipse with application build classpath for external jar to include connector/j driver
7.) wrote a simple java application to test the JDK // worked
8.) wrote test application to connect to mysql using Connector/j. //see connection notes above.
9.) My platform is a windows 7 laptop
10.) tested eclipse java application // "No suitable driver found for jdbc:mysql://localhost:3306/test"
11.) copied same application from Eclipse and saved in Textpad and saved, then ran the following against those java files
from the commandline in windows 7:
javac RetrieveData.java Testing.java OcaSe7ProgrammerStudyTest.java
java -cp mysql-connector-java-5.1.22-bin.jar;. OcaSe7ProgrammerStudyTest //having main in this class
results: "No suitable driver found for jdbc:mysql://localhost:3306/test"
Keep in mind: This appication is a stand alone Swing application, Not using any web servers for this.
Any help or advice on getting the JDBC Driver working would be greatly appreciated.
Items (5) and (10) seem to indicate that you think that Eclipse projects use the classpath you set as a system property. But they don't. Each Eclipse project has its own "build path". Right-click on the project and you'll find an option to configure the build path.