Since our goal in this POC is to first populate our database tables with realistic, synthetic data and then update specific columns within said tables, where data is sensitive, to demonstrate data synthetic data replacement, will need to use GenRocket Receivers that can execute insert and update SQL statements to the database via JDBC.
What is JDBC?
JDBC stands for Java™ database connectivity (JDBC) and is the JavaSoft specification of a standard application programming interface (API) that allows Java programs to access database management systems.
JDBC Configuration Properties File
For GenRocket to connect to a database via JDBC you will need to create a config.properties file. A Java application can connect a SQL database via JDBC by reading a JDBC properties file that contains the following information:
- driver - Defines the name of the specific database driver to use to access the given database. The actual driver file must be placed in the $GEN_ROCKET_HOME/lib folder on your local computer.
- user - Defines the Username used to access the database.
- password - Defines the password used to access the database.
- url - Defines the specific URL to access the database.
- batchCount - Defines the number of SQL statements that are batched together and sent to the database for execution. This property is only mandatory for GenRocket Receivers.
Example JDBC Properties File
The following example JDBC Properties file is based on connecting to a MySQL database. Use this example as a template to create your own config.properties. Complete this step before starting the next part of this lesson.
driver=com.mysql.jdbc.Driver user=root password=admin url=jdbc:mysql://localhost:3306/alpha?rewriteBatchedStatements=true batchCount=1000
For this POC, there are two GenRocket Receivers used to execute SQL insert and SQL update statements on your local computer.
- GenericSQLInsertReceiver - Used to insert a Domain's generated data directly into a database table via a JDBC connection.
- SQLUpdateReceiver - Used for data replacement of values within a database table to guarantee data security.
Defining a JDBC Resource
In order for a GenRocket Receiver that speaks of JDBC to execute successfully on your local computer, a global resource that defines where a JDBC properties file is located on your computer must be defined.
Make sure you have created a config.properties file on your local machine before starting the next lesson.
Step 1 - Adding a Global Resource
- On the Project Dashboard, go to the Resources panel and click on the Add Resource button.
Step 2 - Enter Global Resource information
- Set the Name input field to, resource.jdbc.config
- Set the Description input field to, Location of the database configuration file.
- Click the Save button
Step 3 - Edit your JDBC resource
- Click the edit icon
Step 4 - Define your JDBC resource value
- Set the Value input field to the full path where the JDBC property file is located on your computer
- Click the Save button
Step 5 - Download your Profile
- Click the Dowload My Profile.grp
- Once download is complete, move the profile file to your .genrocket folder.
Step 6 - Set Receiver Default Parameters
This is a one-time setup task to set the default resource parameter on the two JDBC Receivers. This will speed the setup time when assigning a JDBC Receiver to a given Domain. This step of defining the JDBC resource will be removed.
- On the Project Dashboard
- Click the Options menu option
- Click the Manage Default Receiver Parameters menu option
Step 7 - Filter the list of Receivers
- Enter, generic, into the Filter input field
Step 8 - Select to modify the GenericSQLInsertReceiver
- Click the GenericSQLInsertReceiver link
Step 9 - Reference the JDBC resource
- Double click the resourceName input field.
Step 10 - Select the JDBC Resource
- Click the resource.jdbc.config link or click the + icon
Step 11 - Save your modifications
- Click the Save Button
Step 11 - Select to modify the SQLUpdateReceiver
- Enter, update, into the filter
- Click on the SQLUpdateReceiver link
- Repeat step 9 through 11