Next Practical Step
Download your database vendor’s JDBC JAR, drop it into JMeter’s lib/ directory, and run a 1-thread smoke test to verify connectivity.
Benchmark database performance with JMeter JDBC: connection pool tuning, prepared statements, callable queries, variable mapping, and latency assertions.
Apache JMeter enables direct load testing and performance benchmarking of relational databases (PostgreSQL, MySQL, Oracle, MS SQL Server, MariaDB) using JDBC. This allows performance engineers to isolate database query latency, test connection pool limits, benchmark stored procedures, and validate database performance independently of the application layer.
This guide walks through driver installation, connection pool sizing, parameterized queries, and extracting result sets into JMeter variables.
JMeter does not bundle proprietary database drivers. You must download the appropriate JDBC driver .jar file and place it in JMeter’s lib/ directory, then restart JMeter:
| Database | Driver Class Name | Maven / JAR Artifact | Example Database URL |
|---|---|---|---|
| PostgreSQL | org.postgresql.Driver | postgresql-42.x.jar | jdbc:postgresql://localhost:5432/testdb |
| MySQL / MariaDB | com.mysql.cj.jdbc.Driver | mysql-connector-j-8.x.jar | jdbc:mysql://localhost:3306/testdb?useSSL=false |
| Oracle DB | oracle.jdbc.OracleDriver | ojdbc8.jar / ojdbc11.jar | jdbc:oracle:thin:@//localhost:1521/XEPDB1 |
| MS SQL Server | com.microsoft.sqlserver.jdbc.SQLServerDriver | mssql-jdbc-12.x.jar | jdbc:sqlserver://localhost:1433;databaseName=testdb;encrypt=true;trustServerCertificate=true |
The JDBC Connection Configuration config element defines the connection pool.
db_pool_main (Must match the Variable Name in your JDBC Request samplers).50).10000 (ms) — how long a thread waits if all pool connections are occupied before throwing an error.60000 (ms).SELECT 1SELECT 1 FROM DUALDEFAULT (or TRANSACTION_READ_COMMITTED).Add Sampler → JDBC Request under your Thread Group:
db_pool_mainSelect Statement: Standard read queries.Prepared Select Statement: Parameterized read query (prevents SQL injection and improves DB execution plan caching).Prepared Update Statement: INSERT, UPDATE, DELETE operations.Callable Statement: Stored procedure execution.SELECT user_id, email, status, created_atFROM usersWHERE status = ? AND country = ?ORDER BY created_at DESCLIMIT 10;ACTIVE, \${userCountry}VARCHAR, VARCHARuserId, userEmail, userStatus, userCreatedAtWhen you specify variable names in the Variable names field (e.g., userId, userEmail), JMeter automatically parses the result set into indexed variables:
userId_#: Total number of returned rows (e.g., 10).userId_1: First row’s user_id.userId_2: Second row’s user_id.userId_n: nth row’s user_id.userId\${userId_#}currentUserId/api/users/\${currentUserId}.{call process_monthly_invoice(?, ?, ?)}\${accountId}, \${billingCycle}, INOUTINTEGER, VARCHAR, OUT VARCHARMax Number of Connections equal to or greater than the number of active concurrent threads in the Thread Group to prevent threads from blocking on pool locks.