java.lang.ClassNotFoundException: com.mysql.jdbc.Driver when executing JAR

前端 未结 3 472
忘了有多久
忘了有多久 2020-12-17 04:17

I am attempting to connect to my local MySQL server with the following code:

dbURL = \"jdbc:mysql://localhost:3306:/\" + dbname;
try{
    Class.forName(\"com         


        
3条回答
  •  臣服心动
    2020-12-17 05:13

    Install MySQL connector for JAVA

    sudo apt-get install libmysql-java
    

    Set classpath

    export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar
    

    Source: http://marksman.wordpress.com/2009/03/01/setting-up-mysqljdbc-driver-on-ubuntu/

提交回复
热议问题