runtime error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

You need to add a connector library to the Runtime classpath:

java -cp .;mysql-connector-java-5.1.25-bin.jar ClientBase

My example uses Windows classpath separator ";", on other systems it may be different (":" on Linux/Mac). It also assumes, that mysql-connector-java-5.1.25-bin.jar is located on the same folder. If it’s not the case, then put a path to the library instead of the plain name.

ClientBase stands for Java class file name here

c:\>javac Test.java
c:\>java -cp .;F:\CK\JavaTest\JDBCTutorial\mysql-connector-java-5.1.18-bin Test

Leave a Comment