简体   繁体   中英

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

java -jar prog.jar

试试这个java -cp path\\to\\your\\mysql.jar -jar prog.jar

要从命令行运行应用程序,需要将CLASSPATH指定为命令行参数:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM