• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC

 
naveed garg
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51456
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
naveed garg
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is mysql connector jar in your filesystem?

with you are not giving the classpath to your mysql connector
 
naveed garg
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dear, now compile and running fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic