天天看點

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題

一、驅動下載下傳

下載下傳位址:https://downloads.mysql.com/archives/c-j/

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題
說明:需要根據需要下載下傳對應版本的驅動(我使用的MySQL5.7.20,下載下傳的驅動版本為5.1.48)

二、具體配置及執行結果

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題
Database URL:

jdbc:mysql://ip:3306/yytest?allowMultiQueries=true&characterEncoding=UTF-8

           
Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題
Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題

對應資料庫中資料為下圖圈出來的資料(後面2條是新增的,屬于在執行查詢時不存在的資料)

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題

三、遇到問題

1、Cannot create PoolableConnectionFactory (Unknown database ‘yytest&characterencoding=utf-8’)

錯誤資訊:

Cannot create PoolableConnectionFactory (Unknown database

‘yytest&characterencoding=utf-8’)

原因分析:将資料庫URL中的?寫成了&引起。

解決方法:按照錯誤提示将

'yytest&characterencoding=utf-8'

修改為’

yytest?characterencoding=utf-8'

就OK了。

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題

2、Response message: java.sql.SQLException: Cannot create PoolableConnectionFactory

錯誤資訊:

Response message: java.sql.SQLException: Cannot create

PoolableConnectionFactory (The server time zone value ‘?й???׼ʱ?’ is

unrecognized or represents more than one time zone. You must configure

either the server or JDBC driver (via the ‘serverTimezone’

configuration property) to use a more specifc time zone value if you

want to utilize time zone support.)

原因分析:驅動版本不對

解決方法:将使用的最新版的驅動

mysql-connector-java-8.0.20.jar

換成驅動

mysql-connector-java-5.1.48.jar

mysql-connector-java-5.1.48-bin.jar

,就ok了。

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題

具體下載下傳頁面:

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題

四、“allowMultiQueries=true”的作用

MySQL連接配接資料庫時,添加語句:

“allowMultiQueries=true”

的作用:可以使得sql語句中有多個insert或者update語句。如更新已有資料:

Jmeter連接配接MySQL資料庫進行查詢執行個體及遇到問題

繼續閱讀