• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Unable to connect MYSQL :(

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
author & internet detective
Posts: 40801
829
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2659
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 40801
829
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
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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic