wood burning stoves 2.0
The moose likes Beginning Java and the fly likes simple Sql connectivity problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "simple Sql connectivity problem" Watch "simple Sql connectivity problem" New topic
Author

simple Sql connectivity problem

sparsh khandelwal
Ranch Hand

Joined: Dec 20, 2010
Posts: 76
hello everyone
i am trying to connect java file with MySQL database.
although i set the classpath ,copy the exact code from the internet; but still i meet with some problem shown in the snapshot (attached);
i don't have any idea why this happen;
please help



[Thumbnail for ScreenShot002.jpg]

[Thumbnail for ScreenShot003.jpg]

[Thumbnail for ScreenShot004.jpg]

Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1541
    
    5

Hi,

Can you please post output of below command? I assume you are working on Windows OS.

echo %CLASSPATH%


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
sparsh khandelwal
Ranch Hand

Joined: Dec 20, 2010
Posts: 76
thanks for looking my problem
yes i m working on window 7.
the output of the echo %CLASSPATH% is same as the location of jar file of mysqlconnector in my computer


[Thumbnail for ScreenShot005.jpg]

Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1541
    
    5

Hi,

It seems the issue is classpath only. You can try below:

java -cp .;<path_of_your_connector_jar> <name_of_your_class>

I've not worked much on Windows, so please check what is classpath delimeter. I guess its semicolon. So, in above command, classpath contains current directory and connector jar.

Also, please copy paste the output instead of attaching screenshots.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: simple Sql connectivity problem
 
It's not a secret anymore!