天天看點

Could not load JDBC driver class [com.mysql.jdbc.Driver]

我使用Spring JDBC程式設計時,遇到一個錯誤消息:Could not load JDBC driver class [com.mysql.jdbc.Driver]

Could not load JDBC driver class [com.mysql.jdbc.Driver]

完整的錯誤為:

Could not load JDBC driver class [com.mysql.jdbc.Driver]

解決方法:

下載下傳MySQL Connector/J(the official JDBC driver for MySQL).

https://dev.mysql.com/downloads/connector/j/
Could not load JDBC driver class [com.mysql.jdbc.Driver]

将下載下傳的mysql-connector-java.jar添加到Java build path後問題解決:

Could not load JDBC driver class [com.mysql.jdbc.Driver]
Could not load JDBC driver class [com.mysql.jdbc.Driver]
Could not load JDBC driver class [com.mysql.jdbc.Driver]

使用mySQL client指令行可以看到之前用Java JDBC插入的資料庫條目:

Could not load JDBC driver class [com.mysql.jdbc.Driver]