In This Article


How to Connect to a MySQL Database

Step 1 - Create a JDBC Config File (config.properties)

For GenRocket to connect to a MySQL database via JDBC, you must create a JDBC Config or config.properties file. Any application can connect to an MySQL database via JDBC using the information included in this file. Click here to learn more.


Template

   driver=<JDBCDriverClassName>
   user=<userToConnectToDatabase>
   password=<passwordToConnectToDatabase>
   url=<URL>/<databaseName>
   batchCount=1000


Example config.properties for MySQL database

GenRocket will read this config file and connect to an employee database on localhost using username root and password root. If you are connecting to a different type of database, your configuration file will look different. 


driver=com.mysql.jdbc.Driver
user=root
password=root
url=jdbc:mysql://localhost:3306/employee?rewriteBatchedStatements=true
batchCount=1000


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 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 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

Step 6 - Test the JDBC Connection

You can test the JDBC connection before referencing the resource in GenRocket. Click here to learn more. 

Step 7 - Reference the JDBC Resource as Needed

When you create a Scenario containing a Generator or Receiver that references your jdbc.config resource, it will connect directly to your database. GenRocket feature that uses a database connection will also need to reference this file.


Troubleshooting

Error: Access denied for user 'root'@'localhost'

When running the script in the command line, the above error may occur. GenRocket Runtime is trying to make the connection with the MySQL server, but MySQL is not allowing access for the user "root".

If the password for the root user is not set, then you can set the password. Be sure to update it within the config.properties file before trying again.