permaculture playing cards*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 41144
    
  45
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: 41144
    
  45
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 .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc connection
 
Similar Threads
MySQL Connector/J
runtime error in jdbc
ClassNotFoundException
not able to connect to the database
i couldn't run jdbc progam in netbeans