最近在整jmeter壓測數據庫,但是連接到本地數據庫時一直連接不上;
jmeter中報錯信息是 Cannot create PoolableConnectionFactory (Could not create connection to database server.)
查詢了網絡上的資料,很多人說是因為jar版本過低,我的Mysql是8.0.18的版本,jar是5.0.17的版本,確實是比較低;
更換新版本jar包之后還是報錯,jmeter中的報錯信息一直沒變,就去jmeter的運行窗口看了一下,發現報錯如下:
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.
翻譯:不建議在沒有服務器身份驗證的情況下建立SSL連接,根據MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果沒有設置顯式選項,則必須默認建立SSL連接。為了符合不使用SSL的現有應用程序,verifyServerCertificate屬性被設置為“false”。您需要通過設置useSSL=false顯式禁用SSL,或者設置useSSL=true並為服務器證書驗證提供信任存儲。
根據提示,在jmeter的JDBC Connection Configure配置中的Database Connection Configuration --> Database URL中的Url后面加上 '?useSSL=false'即可。
示例 : jdbc:mysql://127.0.0.1:3306/test?useSSL=false
如果有其他參數可以在問號后面使用&符號拼接,示例 : jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false
注意: 我加上 useSSL=false 這個后綴后jmeter中不知道為什么還是會報錯,但是jmeter的運行窗口不再顯示報錯信息,后來重啟了一下jmeter,問題解決!