当前位置:网站首页>高级性能测试系列《24. 通过jdbc执行sql脚本》
高级性能测试系列《24. 通过jdbc执行sql脚本》
2022-07-02 17:59:00 【游戏编程】
目录
- 一、
JDBC(JavaDataBaseConnectivity)1.jdbc:java调用数据库的。2.怎么找jar包?3.mysql版本8与mysql版本5.7的jar包有差异吗? 二、写脚本 1.添加配置元件--
JDBC Connection Configuration。2.jdbc request三、注意
一、 JDBC(JavaDataBaseConnectivity) :
是一种用于执行SQL语句的
JAVA API。通过这个api可以直接执行sql脚本。
1.jdbc:java调用数据库的。
调用数据库时,需要使用jar包(jar包是java语言已经写好的底层的调用类),填写数据库的信息。
jmeter是用java开发的,可以直接执行java代码。
2.怎么找jar包?
某项目的数据库的版本是mysql5.7,所以选择版本号大于5.7的jar包就可以了。
访问服务maven的仓库地址: https://mvnrepository.com/ ,再搜索数据库。
找到你需要的版本,点击版本。 Files--jar ,下载这个jar包。

此时,就下载到本地了。
把下载的jar包,放到jmeter的 lib 文件夹中。

重启jmeter,此时,就可以写jdbc请求了。
有这个jar包之后,jmeter可以发起jdbc请求,没有这个jar包,也有这个jdbc取样器,但是,不能发起请求。
jar包是个第三方 库 。
3.mysql版本8与mysql版本5.7的jar包有差异吗?
现在企业中,用的mysql数据库,一般都是mysql5.7以上版本和mysql8。
mysql5.7版本和mysql5.7以前的版本的性能不一样。
mysql5的版本: 可以选择大于等于你的数据库版本 的任意jar包。
mysql8版本:要选择大于等于你的数据库版本号,一般情况,选择版本号相同的jar包。
mysql8与mysql5的驱动class不一样。
二、写脚本
1.添加配置元件-- JDBC Connection Configuration 。
填写数据库的: ip 、 port 、 dbname 、 user 、 password 、 pool 、字符集 、驱动类.....。variable name for created pool :自定义一个线程池变量名。
变量名命名规则:字母、数字、下划线。不能用数字开头。database Connection Configuration 数据库连接配置。database URL : 填写数据库的ip、端口、dbname。但是,不同的数据库URL地址写法不一样。
mysql的url地址:jdbc:mysql://serverip:port/dbname 。

mysql数据库默认端口:3306,某项目的数据库端口是:3337。jdbc driver class :不同的数据库,这个驱动class不一样。
mysql5的驱动class(是选择的): com.mysql.jdbc.Driver 。 只适用于mysql5版本 。
mysql8的驱动class(是手写的): com.mysql.cj.jdbc.Driver 。兼容mysql5版本。

2.jdbc request
连接池:一定要与 JDBC Connection Configuration 中配置的连接池名称要一致。

sql query:
select \* from cb_account limit 10


运行结果 察看结果树在接收数据的过程中,是要消耗资源的,渲染也要消耗资源的。数据量比较大,时间就会比较长。
真正做性能测试的时候,能不加监听器就不加。
脚本链接:
链接:https://pan.baidu.com/s/1yb1Y-HeVG7QQboL5eeQkRQ?pwd=1234 提取码:1234
三、注意

单独一个s是一个变量, count() 里面可以跟值,不能跟变量。所以, count() 中可以写任意 值 。

图1:count("A"),运行成功。

图2:count(99),运行成功。

图3:count(s)

图3:运行失败。
文章中除标明“图片来自网络”的图片,皆为小编本人所画所截图,计算机知识都一样,如有雷同,纯属巧合。 文章是清菡编写的,如有转载,请标明出处!
欢迎关注 “清菡软件测试”,进群加v:qhtester,备注:学校(公司名)+姓名(昵称),否则不予通过,感谢点赞与分享!
作者:清菡软件测试
游戏编程,一个游戏开发收藏夹~
如果图片长时间未显示,请使用Chrome内核浏览器。
边栏推荐
- [100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning
- R language uses lrtest function of epidisplay package to perform likelihood ratio test on multiple GLM models (logisti regression). Compare whether the performance of the two models is different, and
- High frequency interview questions
- Stratégie touristique d'été de Singapour: un jour pour visiter l'île de San taosha à Singapour
- 消息队列消息丢失和消息重复发送的处理策略
- The second bullet of AI development and debugging series: the exploration journey of multi machine distributed debugging
- juypter notebook 修改默认打开文件夹以及默认浏览器
- Excel如何进行隔行复制粘贴
- ORA-01455: converting column overflows integer datatype
- Progress-进度条
猜你喜欢
![[0701] [paper reading] allowing data imbalance issue with perforated input during influence](/img/c7/9b7dc4b4bda4ecfe07aec1367fe059.png)
[0701] [paper reading] allowing data imbalance issue with perforated input during influence

What is 9D movie like? (+ common sense of dimension space)

Have you stepped on the nine common pits in the e-commerce system?

潇洒郎:彻底解决Markdown图片问题——无需上传图片——无需网络——转发给他人图片无缺失

High frequency interview questions

Introduction to the paper | application of machine learning in database cardinality estimation
![[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference](/img/c7/9b7dc4b4bda4ecfe07aec1367fe059.png)
[0701] [论文阅读] Alleviating Data Imbalance Issue with Perturbed Input During Inference

开发固定资产管理系统,开发固定资产管理系统用什么语音

仿京东放大镜效果(pink老师版)

Mysql高级篇学习总结8:InnoDB数据存储结构页的概述、页的内部结构、行格式
随机推荐
SQL training 2
QT中的QPropertyAnimation使用和toast案列
Mysql高级篇学习总结8:InnoDB数据存储结构页的概述、页的内部结构、行格式
[100 cases of JVM tuning practice] 01 - introduction of JVM and program counter
Novice must see, click two buttons to switch to different content
【每日一题】第二天
第一次去曼谷旅游怎么玩?这份省钱攻略请收好
二进制操作
UML 类图
Learn the knowledge points of eight part essay ~ ~ 1
Leetcode (154) -- find the minimum value II in the rotation sort array
潇洒郎:彻底解决Markdown图片问题——无需上传图片——无需网络——转发给他人图片无缺失
[论文阅读] CA-Net: Leveraging Contextual Features for Lung Cancer Prediction
R language uses Cox of epidisplay package Display function obtains the summary statistical information of Cox regression model (risk rate HR, adjusted risk rate and its confidence interval, P value of
R语言dplyr包filter函数筛选dataframe数据、如果需要筛选的数据列(变量)名称中包含引号则需要使用!!sym语法处理、否则因为无法处理引号筛选不到任何数据
Excel如何进行隔行复制粘贴
[fluent] dart data type (VaR data type | object data type)
metric_logger小解
Learning summary of MySQL advanced 6: concept and understanding of index, detailed explanation of b+ tree generation process, comparison between MyISAM and InnoDB
Compile oglpg-9th-edition source code with clion