File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes not able to connect to the database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "not able to connect to the database" Watch "not able to connect to the database" New topic
Author

not able to connect to the database

Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

got the following error when i try to run java program
Error


Here is the program


here is the classpath


any idea what is the problem
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

When you are using "-cp" switch the "CLASSPATH" environment variable will be ignored, to use the values contained within that you should add that to the "-cp" switch as well. java -cp $CLASSAPTH;. MysqlConnect

P.S:I'm not sure about the delimiter (i.e ; or :).


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

thanks for your reply and got the error which says
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

bash-3.2# java -cp $CLASSPATH MysqlConnect

This should include the directory your class resides as well (this case I think current directory?). Try "java -cp $CLASSPATH;. MysqlConnect" OR "java -cp $CLASSPATH:. MysqlConnect"
Vas Miriyala
Ranch Hand

Joined: Sep 14, 2009
Posts: 114

thats great...thanks Vijitha Kumara it working thanks again
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: not able to connect to the database
 
Similar Threads
simple Sql connectivity problem
Help - - - ClassNotFoundException: com.mysql.jdbc.Driver
ClassNotFoundException Mysql
mysql connection problem
Unable to connect MYSQL :(