• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to connect MYSQL :(

 
naushad qamar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
given below is my code and i am unable to connect mySql database named shop please help me




here is the console result

MySQL Connect Example.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at test.MysqlConnect.main(MysqlConnect.java:15)
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naushad,
Welcome to JavaRanch!

That error is caused by not having the mysql jar in your classpath. Are you running at the command line (DOS or UNIX) or an IDE (Eclipse, Netbeans, etc). Sharing this will allow more specific tips on configuring your classpath.
 
naushad qamar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for reply, I m using eclipse and the .jar file mysql-connector-java-5.1.7-bin is also installed.and i also ping successfully.but i m unable to access my database.
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and the .jar file mysql-connector-java-5.1.7-bin is also installed
How did you do that?
 
naushad qamar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx for reply
i did id by doing this steps
-from my eclipse i went to window tab then data source ->Databases->New ->
Mysql->click on driver button to browse and given the link address of my jar file
i did some thing wrong???
or is there any other way???
 
naushad qamar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx for reply
i did it by doing these steps
-from my eclipse i went to window tab then data source ->Databases->New ->
Mysql->click on driver button to browse and given the link address of my jar file
i did some thing wrong???
or is there any other way???
 
Arunkumar Subramaniam
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
go to project property ---> Java Build Path ----> Library ----> Add External Jars


Arunkumar S
Property.JPG
[Thumbnail for Property.JPG]
Property window screen shot
 
naushad qamar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very very much ,mySql is connected,now i m continue to my work, thanks all of you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad you have it working. I'm going to slide this over to our IDEs forum for anyone who has similar IDE problems.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic