• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple Sql connectivity problem

 
sparsh khandelwal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

ScreenShot002.jpg
[Thumbnail for ScreenShot002.jpg]
ScreenShot003.jpg
[Thumbnail for ScreenShot003.jpg]
ScreenShot004.jpg
[Thumbnail for ScreenShot004.jpg]
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

echo %CLASSPATH%
 
sparsh khandelwal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
ScreenShot005.jpg
[Thumbnail for ScreenShot005.jpg]
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic