aspose file tools*
The moose likes JDBC and the fly likes JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC " Watch "JDBC " New topic
Author

JDBC

naveed garg
Greenhorn

Joined: Mar 01, 2012
Posts: 15
In ubuntu i am complile jdbc program in terminal complile is fine but not run and getting error :

$ javac -cp . ResultSetDemo.java
$ java -cp . ResultSetDemo
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/csapd

please help me thank you
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38844
    
  23
Welcome to the Ranch

Your thread title is hardly informative, I am afraid.

How did you install MySQL? Does it work from the command line? How did you install the driver? Have you got the MySQL manual, which has a section about installing Java™ and JDBC drivers? How did you install the driver? How did you add it to your classpath?
If you are simply using -cp . you will probably need to use an additional classpath entry and it will work.
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
I think you should tell the classloader where to find mysql driver classes. There it will find com.mysql.jdbc.Driver

so:



Hope it helps


Bye,
Nicola
naveed garg
Greenhorn

Joined: Mar 01, 2012
Posts: 15
yes i installed mysql . jdbc program succesfully running in eclipse but in terminal not supporting , i also given classpath of mysql connector ...
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Where is mysql connector jar in your filesystem?

with you are not giving the classpath to your mysql connector
naveed garg
Greenhorn

Joined: Mar 01, 2012
Posts: 15
i make lib file where I insert all jar file , same jar file using in eclipse it is working fine

cs$ javac -cp .:/home/client1/lib ResultSetDemo.java
cs$ java -cp .:/home/client1/lib ResultSetDemo
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/csapd
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
naveed garg wrote:...
cs$ java -cp .:/home/client1/lib ResultSetDemo
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/csapd


you miss the jar name at the end.

naveed garg
Greenhorn

Joined: Mar 01, 2012
Posts: 15
Thanks Dear, now compile and running fine
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC