• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdbc connection

 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am having a simple java program which connects with the mysql database in the path c:\>j2sdk1.4.2_16/bin.when i compile this it compiles well.
I am having my sql.jar file (ie)mysql-connector-java-3.0.17-ga folder which consist of meta-inf and mysql-connector-java-3.0.17-ga-bin.jar in the path c:\>j2sdk1.4.2_16/lib.when i compiled and run my program like this


c:\>j2sdk1.4.2_16/bin/javac Connect.java
c:\>java -classpath .:j2sdk1.4.2_16/lib/mysql-connector-java-3.0.17-ga/lib/mysql-connector-java-3.0.17-ga-bin.jar Connect


It displays the error:


Exception in Thread "main" java.lang.NoClassDefFoundError: Connect


my program is:
.

Thanks.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

public class Connect1


There's your problem - the source file does not contain a class called Connect.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry by mistake i have posted like that.I had given the name correctly.but i am getting error like the same
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The name of the class you are trying to run using the java command and the
is different from the name of your class.

The name of the class should be the same.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thats what i mentioned in the last post.by mistake i have posted wrongly.I have given the class name Connect in the program.

Thanks.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please anyone guide me to do this
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're using a colon to separate the classpath entries. But on Windows, a semicolon is the correct separator.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


c:\>java -classpath .;j2sdk1.4.2_16/lib/mysql-connector-java-3.0.17-ga/lib/mysql-connector-java-3.0.17-ga-bin.jar Connect


you mention java-classpath.;this semicolon...if so i've already given.....
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all.I got the jdbc connection.I set the classpath in environment variables .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic