• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc connection

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • 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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
P. Jain
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
please anyone guide me to do this
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thank you all.I got the jdbc connection.I set the classpath in environment variables .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic