Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java jdbc  RSS feed

 
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
Marshal
Posts: 55678
161
  • 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
Saloon Keeper
Posts: 3997
42
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
Marshal
Posts: 55678
161
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!