Setting Up a JDBC Connection to Query and Update Tables
After setting up a JDBC connection, a process runs the SELECT and UPDATE queries.
Install the PostgreSQL database:
Run JDBC.sql on the PostgreSQL database to create test tables. The script is located in the samples directory under the path TIBCO_HOME\bw\n.n\samples\palette\jdbc\Basic.
- Procedure
- In the samples directory, select and double-click tibco.bw.sample.palette.jdbc.Basic. For more information, see Accessing Samples.
- In the Project Explorer view, expand the tibco.bw.sample.palette.jdbc.Basic project.
- Fully expand
Module Descriptors under
tibco.bw.sample.palette.jdbc.Basic and double-click
Module Properties. The JDBC properties defined for the application are defined in the dialog. Provide a valid username, password, and database URL to connect to your PostgreSQL database.
- Fully expand the
Processes directory and double-click
JDBC_TEST.bwp.
- Verify your JDBC connection.
- Fully expand the Resources directory.
- Double-click JDBCConnection_PostgreSQL.jdbcResource.
- In JDBC Driver, click Click Here to Set Preferences.
- Set the JDBC driver folder directory preference and click Apply. Click OK.
- Click the
Test Connection button to verify the connection.
- Click to save the project.
- Click .
- At the left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
- Click the Applications tab and then click the Deselect All button if you have multiple applications. Select the checkbox next to tibco.bw.sample.palette.jdbc.Basic.application.
- Click
Debug.
This runs the sample in Debug mode.
- Click the
Terminate
icon to stop the process.
- The order_description record in the sub_order table is updated to TESTING JDBC CONNECTION.
Understanding the Configuration
The JDBC_TEST.bwp process uses the JDBC Connection in the Resources folder to establish a connection to the database and run SELECT and UPDATE queries. First it queries the table for a specific record using the JDBC_Query activity and then it updates another table using the JDBC_Update activity. Finally it updates a file indicating the number of records written.
Both activities use prepared parameters as input. This shows the ability to run the same statement with multiple values by caching the statement at runtime.