• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC not working  RSS feed

 
Adam Burda
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I do not understand what I am doing wrong. I'm trying to set the path to the J connector.
Then run a java app to check connection. I get JDBC driver not found
I have the mysql-connector-java-5.1.34-bin.jar placed in C:\Program Files (x86)\Java\jre7\lib folder.
So the path would be C:\Program Files (x86)\Java\jre7\lib\mysql-connector-java-5.1.34-bin.jar
and then in Windows 7 path variables edit, it looks like
......;C:\Program Files (x86)\Java\jdk1.7.0_71\bin;C:\Program Files (x86)\Java\jre7\lib\mysql-connector-java-5.1.34-bin.jar

java version = 7
jdk1.7.0_71
MySQL version = 5.6
MySQL Workbench 6.2 CE
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam,
The driver needs to be in the classpath, not the path. What does your classpath look like?
 
Adam Burda
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no ClassPath in windows 7 only path.
 
Adam Burda
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so I made a ClassPath C:\Program Files (x86)\Java\jre7\lib\mysql-connector-java-5.1.34-bin.jar
then re compiled my app then ran it now I get an error could not find or load main class
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37395
531
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam,
You need to add the current working directory to your classpath as well. So it looks like:

java -cp ".;C:\Program Files (x86)\Java\jre7\lib\mysql-connector-java-5.1.34-bin.jar" YourProgramName
 
Dave Tolls
Ranch Foreman
Posts: 3003
37
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I recommend not storing your jar files in the JRE deployment?
That's not what that lib directory is for.
They should either be stored with your project or server, depending on the app.

You don't want to be polluting your JRE with files completely unrelated to the JRE.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!