In This Article
- Step 1 - Create a JDBC Config File (config.properties)
- Step 2 - (Optional) Encrypt the JDBC Config file
- Step 3 - Update Your JDBC Organization Resource Value
- Step 4 - Update your Profile in the .genrocket Folder
- Step 5 - Download and place the JDBC connector Jar file in the $GENROCKET_HOME/lib/ folder
- Step 6 - Test if Genrocket Runtime can connect to your Postgresql Database
- Step 7 - Reference the JDBC Resource in your Generators or Receivers
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=1000
Example 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=1000
Note: 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. Click here to learn more.
Step 3 - Update Your JDBC Organization Resource Value
The resource.jdbc.config Organization Resource specifies the location of the JDBC Config file on the logged in user's local machine. This resource value should contain the full directory path (e.g., /home/user/dev). Click here to see step-by-step instructions.
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 read this resource value from your profile on your system to make a connection with the database. Click here 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.