GeeCON Prague 2014*
The moose likes JDBC and the fly likes jdbc connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc connection " Watch "jdbc connection " New topic
Author

jdbc connection

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
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
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
public class Connect1

There's your problem - the source file does not contain a class called Connect.


Ping & DNS - my free Android networking tools app
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
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

Joined: Jan 03, 2008
Posts: 15
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.


SCJP 5.0<br />SCWCD 5.0<br />Preparing for SCDJWS
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
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

Joined: Oct 04, 2007
Posts: 518
please anyone guide me to do this
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
You're using a colon to separate the classpath entries. But on Windows, a semicolon is the correct separator.
preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518

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

Joined: Oct 04, 2007
Posts: 518
Thank you all.I got the jdbc connection.I set the classpath in environment variables .
 
GeeCON Prague 2014
 
subject: jdbc connection