This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes Unable to connect MYSQL :( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Unable to connect MYSQL :(" Watch "Unable to connect MYSQL :(" New topic
Author

Unable to connect MYSQL :(

naushad qamar
Greenhorn

Joined: May 31, 2009
Posts: 10
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

Joined: May 26, 2003
Posts: 32304
    
213

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.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
naushad qamar
Greenhorn

Joined: May 31, 2009
Posts: 10
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

Joined: Dec 20, 2006
Posts: 2541
    
  10

...and the .jar file mysql-connector-java-5.1.7-bin is also installed
How did you do that?


OCUP UML fundamental and ITIL foundation
naushad qamar
Greenhorn

Joined: May 31, 2009
Posts: 10
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

Joined: May 31, 2009
Posts: 10
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

Joined: Apr 08, 2009
Posts: 8
hi
go to project property ---> Java Build Path ----> Library ----> Add External Jars


Arunkumar S



[Thumbnail for Property.JPG]

naushad qamar
Greenhorn

Joined: May 31, 2009
Posts: 10
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

Joined: May 26, 2003
Posts: 32304
    
213

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.
 
 
subject: Unable to connect MYSQL :(
 
It's not a secret anymore!