mysql java connection error
I am running my JAR file in linux (centos). All jar files work fine.
Now i am trying to connect to mysql server, but it gave me following error.
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I don't have server root access. I have a simple user account. I downloaded mysql.jar file for db connection, and put that in lib folder. Jar file contains lib path in .CLASSPATH file.
EDIT
I am running Jar file at command line
jav开发者_开发问答a -jar prog.jar
Try this java -cp path\to\your\mysql.jar -jar prog.jar
To run the application from the command line you need to specify the CLASSPATH as a command line argument:
java -cp mysql.jar -jar prog.jar
The .CLASSPATH file is an eclipse project file which will not be used when executing from the command line. Try following this guide to set your classpath.
精彩评论