昨天把Mysql裝好了,這個躺在草稿中很久的文章也可以出爐了。
首先需要準備個Mysql jdbc驅動包,盡量保證其版本和你的數據庫版本一致,至少不低于數據庫版本,否則可能有問題。去官網扒一個下來吧:https://dev.mysql.com/downloads/connector/j/
1、測試計劃(Test Plan)下面把jdbc驅動包導入。
2、線程組下添加一個配置元件JDBC Connection Configuration。
Variable Name:自定義參數,在JDBC Request中會用到;
Database URL:jdbc:mysql:// 數據庫IP地址:數據庫端口/數據庫名稱;
JDBC Driver Class:com.mysql.jdbc.Driver;
Username:數據庫用戶名;
Password:數據庫密碼;
3、在添加一個Sampler:JDBC Request,順手加個結果樹。
--------------------------------------分割線---------------------------------------
上述過程中,執行之后結果樹中出現了一個報錯:
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.)
解決如下:
在database url后面加上?serverTimezone=UTC,其中UTC是統一標準世界時間。
解決中文亂碼輸入問題,可以在database url后面加上?useUnicode=true&characterEncoding=UTF-8。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。
原文鏈接:https://www.cnblogs.com/zichuan/p/9186274.html