Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java jdbc

 
dhanil das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir, I got some errors when i execute my first java program to connect the "MYSQL" database ,here is the code



it compiles successfully , but show this error during running ,

:>java JdbcConnection

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

please help me



 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not have MySQL driver in your classpath.
It is a jar file with a name like: mysql-connector-java-5.1.5-bin.jar, include it in your classpath.
 
dhanil das
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply sir , here i got the solution to our problem ,here it is

set path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Sun\SDK\bin;C:\Program Files\Java\jdk1.6.0_03\bin;;C:\Program Files\Java\jdk1.6.0_03\bin;


set classpath=;C:\Program Files\Java\jdk1.6.0_03\bin;;C:\ProgramFiles\Java\jdk1.6.0_03\bin;C:\mysql-connector-java-5.0.8\mysql-connector-java-5.0.8-bin.jar;


thank you sir

 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't put your Java installation folders in your CLASSPATH. Don't keep your own work in your Java installation folder.
 
avijit majumder
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put the mysql driver on your project folder or where the java file run.
the driver -->.JAR File name is mysql-connector-java-3.1.11-bin.jar . [download it from net]
then extract it
after extract three folder com,META-INF,org apper.
Now Run the file. ___IT WORK.
 
nick kaushik
Ranch Hand
Posts: 48
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why does he have path defined 2 times?
C:\Program Files\Java\jdk1.6.0_03\bin;;C:\Program Files\Java\jdk1.6.0_03\bin;................?
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nick kaushik wrote:why does he have path defined 2 times?
C:\Program Files\Java\jdk1.6.0_03\bin;;C:\Program Files\Java\jdk1.6.0_03\bin;................?

Only one is required. If you have more (for several JDK versions) first one is taken.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does no harm to have the same thing twice in one's PATH. We only get complaints when something isn't in the PATH at all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic