How to parametrize Database URL under JDBC Connection Configuration? Normal parametrization is not working here.
This doesn't work:
Database URL: jdbc:mysql://${mysql_hostname}:${mysql_port}/${mysql_database}
JDBC Driver Class: com.mysql.jdbc.Driver
Username: ${mysql_username}
Password: ${mysql_username}
The JDBC Connection Configuration is used to configure JMeter connections to the database. 5. Fill in the Variable Name field. The value of this field is used to associate a specific connection configuration (JDBC Connection Configuration) to the database and a specific request (JDBC Request) sent by JMeter.
JMeter can connect to any database and run SQL queries concurrently. In order to do so, it's mandatory to have necessary JDBC drivers in the lib folder of your installation. Most important part of the Database performance testing is to have valid connection strings in JDBC Connection Configuration.
protocol – jdbc:mysql: host – mysql. db. server:3306.
Run tests with just the JMeter client Copy the JDBC Driver file to /usr/local/jmeter/lib.
The point is that JDBC Connection Configuration test element is being initialized before JMeter Variables so if you want to parameterize it you should be doing it a little bit differently to wit:
Use __P() function where required like:
Database URL: jdbc:mysql://${__P(mysql_hostname,)}:${__P(mysql_port,)}/${__P(mysql_database,)}
JDBC Driver Class: com.mysql.jdbc.Driver
Username: ${__P(mysql_username,)}
Password: ${__P(mysql_password,)}
The relevant JMeter Properties can be set either in user.properties file like:
mysql_hostname=localhost
mysql_port=3306
mysql_database=test
mysql_username=johndoe
mysql_passowrd=secret
Or via -J command-line argument like:
jmeter -Jmysql_hostname=localhost -Jmysql_port=3306 -Jmysql_database=test -Jmysql_usename=johndoe -Jmysql_password=secret
See Apache JMeter Properties Customization Guide for more information on JMeter Properties and ways of setting and overriding them
in Jmeter (5.1.1) you can use 'User Defined Variables'. Add-> Config Element -> User Defined Variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With