Search code examples
javamysqlconnectionclassnotfound

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


Solution

  • Try this java -cp path\to\your\mysql.jar -jar prog.jar