How do I connect to a PostgreSQL database with GenRocket Runtime?
Learn how to establish a connection to a PostgreSQL database using GenRocket Runtime for efficient data generation.
Step 1 - Create a JDBC Config File (config.properties)
For GenRocket to connect to a PostgreSQL database via JDBC, you must create a JDBC Config File (config.properties). Any application can connect to a PostgreSQL database via JDBC by reading the information included in this file. A template and example are shown below. Click here to learn more.
Template
driver=<JDBCDriverClassName>
user=<userToConnectToDatabase>
password=<passwordToConnectToDatabase>
url=<URL>/<databaseName>
batchCount=1000Example config.properties for PostgreSQL Database
GenRocket will read this config file and connect to a sample database on a user's local machine using port 5432.
driver=org.postgresql.Driver
user=username
password=password
url=jdbc:postgresql://localhost:5432/sample
batchCount=1000Note: You can learn more about the URL property for a PostgreSQL database by clicking here.
Step 2 - (Optional) Encrypt the JDBC Config File
You can encrypt this file for additional security. View How do I Encrypt Config and Property Files? to learn more.
Step 3 - Update Your JDBC Organization Resource Value
The resource.jdbc.config Organization Resources specifies the location of the JDBC Config file on the logged in user's machine. This resource value should contain the full directory path (e.g., /home/user/dev). See How Do I Change Resource Values and Download My User Profile? for more information.
Step 4 - Update your Profile in the .genrocket Folder
Each user has a profile stored in the .genrocket folder on their local machine. You must download and replace your profile (in ~/.genrocket folder). GenRocket will reach this resource value from your profile on your system to make a connection with the database. See How Do I Change Resource Values and Download My User Profile? for more information.
Step 5 - Download and place the JDBC connector Jar file in the $GENROCKET_HOME/lib/folder
- Download and place a PostgreSQL connector in your genrocket/lib folder
- You can download the latest version of PostgreSQL connector at this link
Step 6 - Test if Genrocket Runtime can connect to your Postgresql Database
You can test the JDBC connection before referencing the resource in GenRocket. Click here to learn more.
Step 7 - Reference the JDBC Resource in your Generators or Receivers
When you create a Scenario with a Generator or Receiver that references your created jdbc.config.directory resource and config file, it will connect directly to your database.
Troubleshooting
If you still need help connecting to your PostgreSQL database via JDBC, please contact support@genrocket.com.
Article Feedback: Was this helpful?
Give feedback