1. 沒有添加jar程序驅動包導致出現以下問題,即無法找到驅動類。
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
解決方法是可以在
http://www.mysql.com/downloads/connector/j 手動下載Java連接MySQL的最新驅動包,通過intellij idea導入即可。
點擊 File -> Project Structure(快捷鍵 Ctrl + Alt + Shift + s),點擊Project Structure界面左側的“Modules”;
在 “Dependencies” 標簽界面下,點擊右邊的 “+”號,選擇第一個選項“JARs or directories...”,選擇相應的jar包,點“OK”,jar包添加成功。其他類似錯誤也可以通過導包解決。 具體可以參考
http://jingyan.baidu.com/article/fec7a1e5f79e2b1191b4e74f.html
static final String DB_URL = "jdbc:mysql://localhost/test";
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
解決方法是可以在
http://www.mysql.com/downloads/connector/j 手動下載Java連接MySQL的最新驅動包,通過intellij idea導入即可。
點擊 File -> Project Structure(快捷鍵 Ctrl + Alt + Shift + s),點擊Project Structure界面左側的“Modules”;
在 “Dependencies” 標簽界面下,點擊右邊的 “+”號,選擇第一個選項“JARs or directories...”,選擇相應的jar包,點“OK”,jar包添加成功。其他類似錯誤也可以通過導包解決。 具體可以參考
http://jingyan.baidu.com/article/fec7a1e5f79e2b1191b4e74f.html
static final String DB_URL = "jdbc:mysql://localhost/test";
static final String USER = "root";
static final String PASS = "root123";
程序中對應的數據庫名稱改為自己的數據庫名稱,我的是test;用戶和密碼也改成自己的數據庫相對應的,否則會報錯。
static final String PASS = "root123";
程序中對應的數據庫名稱改為自己的數據庫名稱,我的是test;用戶和密碼也改成自己的數據庫相對應的,否則會報錯。
2. web應用中連接mysql數據庫時后台會出現這樣的提示:
Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
原因是MySQL在高版本需要指明是否進行SSL連接。解決方案如下:
在mysql連接字符串url中加入ssl=true或者false即可,如下所示。
url="jdbc:mysql://127.0.0.1:3306/framework?characterEncoding=utf8&useSSL=true"
Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
原因是MySQL在高版本需要指明是否進行SSL連接。解決方案如下:
在mysql連接字符串url中加入ssl=true或者false即可,如下所示。
url="jdbc:mysql://127.0.0.1:3306/framework?characterEncoding=utf8&useSSL=true"
3. 圖形化界面連接的時候如果測試通不過
(1)出現部分的亂碼,是因為MySQL版太高
(2)導的jar包不是對應的MySQL版本
