• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC not working

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41919
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41919
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 4801
50
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I'm so happy! And I wish to make this tiny ad happy too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic