jdbc插入数据没有给默认值_jmeter操作数据库

一.JDBC Connection Configuration用法

eb59100e198dbcc2daed4c03292f0b9c.png
img

(1) Variable Name Bound to Pool

Variable Name,数据库连接池的变量名,之后JDBC request可以通过选择不同的连接池名来选择不同的数据库连接

Variable name变量名称:与JDBC Request的Variable name保持一致

原因:因为链接数据库是需要在JDBC Connection Configuration中配置好的,然后赋予一个变量名称,那么JDBC Request想要去访问数据库,就必须通过这个配置好的元件去链接,所以JDBC Reques就需要通过读取JDBC Connection Configuration的变量中的信息,

那怎么读取呢,JDBC Reques就需要用到这个变量了,就需要到名称为mysql的元件中去应用。

(2) Connection Pool Configuration

Max Number of Connections   该数据库连接池的最大连接数,一般可设置为0,意思是每个线程都使用单独的数据库连接,线程之间数据库连接不共享 中文:池中允许的最大连接数。在大多数情况下,将其设置为0,这意味着每个线程将得到它自己的池,其中只有一个连接,即线程之间不共享连接。如果您真的想要使用共享池(为什么?),那么将max count与线程数相同,以确保线程不会相互等待。 原文:aximum number of connections allowed in the pool. In most cases, set this to zero (0) . This means that each thread will get its own pool with a single connection in it, i.e. the connections are not shared between threads. If you really want to use shared pooling (why?), then set the max count to the same as the number of threads to ensure threads don't wait on each other.

Max Wait (ms)  在连接池中取回连接最大等待时间 中文:如果在试图检索连接过程中(取回连接)超过所设置期限,连接池抛出一个错误 原文:ool throws an error if the timeout period is exceeded in the process of trying to retrieve a connection

Time Between Eviction Runs (ms)   疏散时间 中文:在空闲对象驱逐线程运行期间,可以休眠的毫秒数。当非正值时,将运行无空闲对象驱逐器线程。(默认为“60000”,1分钟)(如果当前连接池中某个连接在空闲了time Between Eviction Runs Millis时间后任然没有使用,则被物理性的关闭掉。) 原文:The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run. (Defaults to " 60000 ", 1 minute)

Auto Commit   自动提交sql语句 中文:打开或关闭连接的自动提交。 原文:Turn auto commit on or off for the connections.

(3) Connection Validation by Pool

这是Jmeter用来检验数据库连接是否有效的一种机制,超过5秒没有使用的话,就会用validation query去测试下这个连接是否有效

Test While Idle  当空闲的时候测试连接是否断开 中文:测试连接池的空闲连接,验证查询将会被使用去测试。 原文:Test idle connections of the pool, see BasicDataSource.html#getTestWhileIdle . Validation Query will be used to test it.

Soft Min Evictable Idle Time(ms)
中文:最少的时间连接可能在池中闲置,然后才有资格被闲置的对象驱逐出去,额外的条件是至少在池中保持连接。默认值为5000(5秒) 原文:Minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the idle object evictor, with the extra condition that at least minIdle connections remain in the pool. See BasicDataSource.html#getSoftMinEvictableIdleTimeMillis . Defaults to 5000 (5 seconds)

(4) Database Connection Configuration

Database URL: jdbc:mysql://服务器地址:3306/数据库名

(比如:jdbc:mysql://ip:3306/数据库名?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true)

备注:“&allowMultiQueries=true” 这句话的意思呢  是为了在JDBC中执行多条select语句的时候用的!

JDBC Driver class:数据库JDBC驱动类名:com.mysql.jdbc.Driver

Username:数据库连接用户名

password:数据库连接密码

二.JDBC Request用法

e7612e7265480cf7188768358286a773.png
img

重要参数说明:

Parameter valus:参数值

Parameter types:参数类型,可参考:Javadoc for java.sql.Types

Variable names:保存sql语句返回结果的变量名,返回多少个需要设置多少个变量名

Result variable name:创建一个对象变量,保存所有返回的结果

Query timeout:查询超时时间

Handle result set:定义如何处理由callable statements语句返回的结果

三.常用数据库驱动类和URL格式(JDBC Connection Configuration)

DatebaseDriver classDatabase URL
MySQLcom.mysql.jdbc.Driverjdbc:mysql://host:port/{dbname}
PostgreSQLorg.postgresql.Driverjdbc:postgresql:{dbname}
Oracleoracle.jdbc.driver.OracleDriverjdbc:oracle:thin:@//host:port/service ORjdbc:oracle:thin:@(description=(address=(host={mc-name})(protocol=tcp)(port={port-no}))(connect_data=(sid={sid})))
Ingres (2006)ingres.jdbc.IngresDriverjdbc:ingres://host:port/db[;attr=value]
MSSQLcom.microsoft.sqlserver.jdbc.SQLServerDriver或者net.sourceforge.jtds.jdbc.Driverjdbc:sqlserver://IP:port;databaseName=DBname或者jdbc:jtds:sqlserver://localhost:1433/"+"library"

四.常见错误:

1.执行时报错Cannot load JDBC driver class 'com.mysql.jdbc.Driver'

解决方法:

下载和mysql数据库版本一致的驱动,放入{jmeter-HOME}/lib/目录下,重启jmeter应用即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值