How to Connect to External Microsoft SQL Server 2016 Database from Pega 7.1.9

In this example, the Pega 7.1.9 Connector and Metadata Wizard in the Designer Studio is used to create connectivity between a Pega 7 application and an external Microsoft SQL Server database table. This wizard will generate the necessary PRPC rules for mapping to the table’s columns and for browsing, inserting, updating and deleting records.

Related Posts


  1. Software and Setup used in this Example
  2. Installation of Microsoft SQL Server Developer Edition
  3. Setup of Microsoft SQL Server Management Studio
  4. Setup of Sample Database “FlightInformation
  5. Create User Account for Pega 7 JDBC Connectivity to MS SQL Server
  6. Confirm that the MS SQL Server Accepts JDBC Connections
  7. Configuration of Pega 7.1.9 prconfig.xml for MS SQL Server JDBC Support
  8. Setup of new MS SQL Server Database Instance in Pega 7.1.9
  9. Execution of Pega 7.1.9 Connector and Metadata Wizard for External DB Table
  10. Browse the External SQL Server Table with an Activity

  • Pega 7.1.9 installed as a Personal Virtual Server (PVS) running on Oracle VM VirtualBox as described in the exercise system section of the System Architect Essentials course on Pega Academy. See Pega training courses for how to register and download a Pega 7 PVS.
  • The host operating system (running Pega PVS and Microsoft SQL Server) is Windows 10 64-bit.
  • The virtual machine running Pega 7.1.9 was configured to use a Host-only Adapter and DHCP.
  • In this example, the IP address of the Pega 7 virtual machine is
  • In this example, the IP address of the Windows 10 host OS is

Oracle VirtualBox, Network Host-only

Microsoft SQL Server Download Website

  • It is necessary to create a Microsoft account or to login with an existing account. Once that is done, the Visual Studio Dev Essentials page will show a link to download the Microsoft SQL Server Developer Edition.
  • Visual Studio Dev Essentials can be accessed directly through this link.

Microsoft Visual Dev Studio, Tools Download

  • An installation file, called SQLServer2016-SSEI-Dev.exe, will be downloaded.
  • Execute the installation file to start the installation wizard.
  • For this example, the Basic installation type was used.

MS SQL Server Instllation, Select Basic Installation Type

  • Click on the Accept button to accept the Microsoft SQL Server 2016 License Terms.

MS SQL Server Instllation, Accept License Agreement

  • The next screen allows to specify SQL Server install location. For this example, the default location for Windows C:\Program Files\Microsoft SQL Server was used.

MS SQL Server Instllation, Select Installation Location

  • Click on the Install button to start the installation process.
  • The installer will first download the SQL Server software and then install it.

MS SQL Server Instllation, Downloading Installation Package

  • After the installation completed successfully, a confirmation screen is shown.

MS SQL Server Instllation, Installation Complete

  • Click on the Close button to exit the installation wizard.
  • A computer restart is required to complete the installation.

Microsoft SQL Server Configuration Manager, MSSQLSERVER Service is Running

  • Confirm that the MSSQLSERVER service is running. On Windows, use the SQL Server Configuration Manager.

  • The SSMS provides a graphical user interface for developing and managing SQL Server databases.
  • Download the application from the Microsoft SSMS Download page and run the file SSMS-Setup-ENU.exe and follow the installation wizard’s instructions.

Microsoft SQL Server Management Studio, Installation

  • After the installation, run the application link Microsoft SQL Server Management Studio from the Windows Start menu.

Microsoft SQL Server Management Studio, Initial Screen Connected to Local MS SQL Server Instance

  • The SSMS should automatically connect to the locally running SQL Server instance. If prompted, login with Windows user credentials.

  • A sample database and table was created for holding flight information.
  • The flight information table will be used to access its data from Pega 7.1.9.
  • In SSMS, a new database can created by right-clicking on the MS SQL Server instance and selecting Databases > New Database

Microsoft SQL Server Management Studio, New Database Menu Item

Microsoft SQL Server Management Studio, New Database Options, Partial Containment Type

  • A table can be created by right-clicking on Tables > New > Table.

Microsoft SQL Server Management Studio, Create New Table

  • In this example, a table called dbo.Flights with the following columns was created:
  • id – Auto-generated identifier (…enable Identity Specification for this column)
  • flightNumber – The flight number
  • airline – Name of the airline
  • departureTime – Departure date and time
  • arrivalTime – Arrival date and time
  • fromAirport – The origin airport name
  • toAirport – The destination airport name
  • price – The flight ticket price
  • Use the SQL CREATE TABLE command below to create the Flights table with a DDL statement.
  • Note: I used the char column type because nvarchar and nchar table column mapping did NOT work when running the Connector and Metadata Wizard in Pega 7.1.9.
CREATE TABLE [dbo].[Flights](
    [id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
    [flightNumber] [char](6) NOT NULL,
    [airline] [char](25) NOT NULL,
    [departureTime] [datetime] NOT NULL,
    [arrivalTime] [datetime] NOT NULL,
    [fromAirport] [char](25) NOT NULL,
    [toAirport] [char](25) NOT NULL,
    [price] [money] NOT NULL,
    [id] ASC

Microsoft SQL Server Management Studio, Flights Table Structure

  • 11 records were inserted into the dbo.Flights table as shown in the screen shot below.

Microsoft SQL Server Management Studio, Flights Table Data

  • The below SQL INSERT statements can be used to create the sample data.
INSERT INTO [dbo].[Flights] VALUES ('SA0078', 'Spirit Airlines', '2017-02-07 14:25:00.000', '2017-02-07 21:45:00.000', 'Fort Lauderdale (FLL)', 'Los Angeles (LAX)', 414.69);
INSERT INTO [dbo].[Flights] VALUES ('SA0079', 'Spirit Airlines', '2017-02-07 09:15:00.000', '2017-02-07 14:55:00.000', 'Fort Lauderdale (FLL)', 'Los Angeles (LAX)', 975.99);
INSERT INTO [dbo].[Flights] VALUES ('AA1122', 'American Airlines', '2017-02-10 05:35:00.000', '2017-02-10 08:40:00.000', 'Miami (MIA)', 'New Orleans (MSY)', 328.65);
INSERT INTO [dbo].[Flights] VALUES ('AA1078', 'American Airlines', '2017-02-07 09:38:00.000', '2017-02-07 18:05:00.000', 'West Palm Beach (PBA)', 'New York (JFK)', 1225.49);
INSERT INTO [dbo].[Flights] VALUES ('UA0768', 'United', '2017-03-01 10:00:00.000', '2017-03-01 12:15:00.000', 'Chicago (ORD)', 'Dallas (DFW)', 546);
INSERT INTO [dbo].[Flights] VALUES ('UA0768', 'United', '2017-03-02 10:00:00.000', '2017-03-02 12:15:00.000', 'Chicago (ORD)', 'Dallas (DFW)', 595.9);
INSERT INTO [dbo].[Flights] VALUES ('CA1718', 'Copa Airlines', '2017-02-15 07:55:00.000', '2017-02-15 09:55:00.000', 'San Francisco (SFO)', 'Fresno (FAT)', 316);
INSERT INTO [dbo].[Flights] VALUES ('AC7878', 'Air Canada', '2017-02-05 07:59:00.000', '2017-02-05 10:09:00.000', 'San Francisco (SFO)', 'Seattle (SEA)', 725.78);
INSERT INTO [dbo].[Flights] VALUES ('BA0286', 'British Airways', '2017-03-05 10:52:00.000', '2017-03-06 05:52:00.000', 'San Francisco (SFO)', 'London (LHR)', 3219.45);
INSERT INTO [dbo].[Flights] VALUES ('CH9654', 'China Airlines', '2017-03-05 07:32:00.000', '2017-03-05 07:52:00.000', 'San Francisco (SFO)', 'Shanghai (PVG)', 2199);
INSERT INTO [dbo].[Flights] VALUES ('AA3104', 'Alitalia', '2017-02-26 11:15:00.000', '2017-02-27 10:35:00.000', 'San Francisco (SFO)', 'Milan (MXP)', 4056.99);

  • It is also necessary to create a new database user account for JDBC access from Pega 7.
  • Navigate to Security > Users. Right-click to open the context menu and select New User…

Microsoft SQL Server Management Studio, Create New User Menu

  • In the Database User – New form, select "SQL user with password" for the user type.
  • Enter a user name, in this case it is pega7User and a password, here it is rules.
  • In this example, the Flights table is part of the dbo schema and it should be selected as the default one.

Microsoft SQL Server Management Studio, User Account for Pega 7 JDBC Remote Access

  • In the Database User – New form, navigate to Membership and check the option db_datareader and if needed, db_datawriter for inserting data from Pega 7.

Microsoft SQL Server Management Studio, New User Account Permissions

  • Click on OK to save the user account and close the dialog.

  • By default, the MS SQL Server Developer Edition is configured to NOT allow TCP/IP connections.
  • In order to allow remote JDBC clients to connect to the MS SQL Server instance, the SQL Configuration Manager needs to be used to change TCP/IP network settings.
  • Navigate to SQL Server Network Configuration > Protocols for MSSQLServer and enable the TCP/IP protocol as shown below.

SQL Configuration Manager, Enable TCP/IP Protocols for Remote Access

  • A simple Java program can be used to confirm that the pega7User user account and network configuration changes were done correctly and that the MS SQL Server accepts remote JDBC connections. Copy the below Java code into a file named
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MSSqlServerDAO {
    public Connection getConnection(
            String host, 
            String port,
            String db,
            String user, 
            String pwd) throws SQLException {
        String connectionString = "jdbc:sqlserver://" + host + ":" + port 
                + ";databaseName=" + db + ";user=" + user + ";password=" + pwd;

        return DriverManager.getConnection(connectionString);
    public static void main(String[] args) throws SQLException {
        // Establish a JDBC connection
        Connection c = new MSSqlServerDAO().getConnection(
            "", /* or for Virtual Box Host-only adapter IP */

        // Execute a query
        Statement stmt =  c.createStatement();
        ResultSet rs = stmt.executeQuery(
                "SELECT * FROM [dbo].[Flights]");
        // Process and print the query results
        while ( {            
            int id = rs.getInt("id");
            String flightNumber = rs.getString("flightNumber");
            String airline = rs.getString("airline");
            Float price = rs.getFloat("price");
            System.out.printf("%-5d %-9s %-17s   $%.2f\r\n", id, flightNumber, airline, price);
  • Download the Microsoft JDBC Driver 6.0 for SQL Server and save it to some folder.
  • Copy the Java file into the same folder.
  • From the command line, compile the program using the syntax shown below.
  • After successful compilation, the folder should contain a file named MSSqlServerDAO.class.
"<JDK_BIN_PATH>\javac" -cp <JDBC_DRIVER_FILE_PATH>\sqljdbc42.jar

Java JDBC Program for MS SQL Server Access

  • Execute the Java class file using the syntax given below. The program will connect to the specified MS SQL Server instance, execute a query and print the first 3 columns of the result set.
"<JRE_BIN_PATH>\java" -cp .;<JDBC_DRIVER_FILE_PATH>\sqljdbc42.jar MSSqlServerDAO

Run Java JDBC Program for MS SQL Server Access

  • If the program fails to connect to the MS SQL Server instance, indicating a TCP/IP communication failure, check the host system’s firewall and make appropriate changes so that TCP/IP communication on port 1443 is allowed.

  • It is necessary to copy the MS SQL Server JDBC driver file to the Pega 7.1.9 PRPC web application and to modify the PRPC prconfig.xml file so that Pega can load the JDBC driver.
  • Use the virtual machine’s command line interface (login is root / install) to get the IP address of the Pega virtual machine. Here, it is:

Oracle VirtualBox, Pega 7 Private Virtual Server Login

  • A FTP client such as FileZilla can be used to copy the sqljdbc42.jar JDBC driver file to the PRPC web application’s lib folder. In this case, i.e. Pega 7.1.9 PVS using Tomcat 7, the folder is:
  • On a Pega 7.1.6 PVS exercise system, the folder is:
  • The default SFTP username and password for a Pega 7.1.9 Private Virtual Server (exercise system installation) is root and password.

Use FileZilla to copy sqljdbc driver to Pega 7 Private Virtual Server

  • Using an FTP client, download the prconfig.xml file and open it locally in a text editor.
  • On Pega 7.1.9, the PRPC configuration file is located under:
  • On Pega 7.1.6, the PRPC configuration file is located under:

Use FileZilla to download Pega 7 prconfig file

  • Modify the prconfig.xml file to add an entry for the MS SQL JDBC Driver Class as shown below.
<env name="database/drivers" value="" />

Modify Pega 7 prconfig File for MS SQl Server JDBC Driver Support

  • Upload the prconfig.xml file back to the virtual machine.
  • Access the Tomcat 7 Manager Application through a browser, here the address is:
  • By default, the username and password is admin and admin.

Use Tomcat 7 Manager Application to Restart Pega 7 prweb Application

  • Reload the PRPC web application using the Reload button for the prweb application.

  • Open the Designer Studio, here, the URL is:
  • On Pega 7.1.9 PVS exercise system, the admin login is [email protected] and install.
  • Navigate to Records > Sysadmin > Database to view all instances of external DB connections.
  • Click on the +Create button to add a new external database.

Pega 7 Designer Studio, Create New Database Instance

  • On the next screen, enter a name and description for the new external database instance.
  • Click on Create and open to proceed.

Pega 7 Designer Studio, New Database Instance Name and Description

  • On the Edit Database form select "use JDBC URL listed below" in the first drop-down.
  • In the JDBC definition text field, enter the JDBC URL. In this case, the URL is:
  • Enter the MS SQL Server user credentials created in section 5. Here the username is pega7User and the password is rules.

Pega 7 Designer Studio, New Database Instance Configuration

  • Test the connection by clicking on the Test Connection button on the bottom of the form.

Pega 7 Designer Studio, New Database Instance, Test Connection Success

ERROR: No Suitable Driver Found

  • Verify that the prconfig.xml file has been modified as shown in section 7 to make the JDBC driver available to PRPC.

Pega 7 Designer Studio, New Database Instance, Test Connection Failure, No Suitable Driver Found

ERROR: TCP/IP connection to the host…has failed

  • Verify that MS SQL Server is configured to accept incoming TCP/IP connections (see section 6).
  • Check MS SQL Server host OS firewall. Make sure TCP/IP connections on port 1443 are allowed.

Pega 7 Designer Studio, New Database Instance, Test Connection, TCP/IP Connection Failure

  • Here, the MS SQL Server is running on Windows 10.
  • For temporary debugging, the Windows Firewall can be turned off as shown below.

Windows 10, Disable Firewall

ERROR: TCP/IP connection to the host…has failed

  • Here, Pega 7 PVS is running on a virtual machine with an IP address of
  • MS SQL Server may not accept connections from this IP address.
  • The SQL Server Configuration Manager can be used to allow incoming IP addresses.

SQL Server Configuration Manager, TCP/IP Settings

For more information on MS SQL Server connection troubleshooting refer to:

  • In the Pega 7 Designer Studio main menu, navigate to Integration > Connectors > Connector and Metadata Wizard >

Pega 7 Designer Studio, Select Connector and Metadata Wizard

1. Choose Purpose

  • Purpose: Generate Connector Rules
  • Metadata Type: SQL
  • Integration rule set name and version: here PGX- and 01-01-01
  • Base class for integration and data model rules: here PGX-
  • Connector Activity Class: container for browse, insert, update and delete activities

Connector and Metadata Wizard Step 1 - Choose Purpose

2a. Process Metadata – Select Database Table

  • Database Name: FlightInformation (…external MS SQL Server DB as configured in section 7)
  • Schema Name: dbo (…this schema contains the table, see section 4)
  • Table Name: Flights (…the table name in MS SQL Server)

Connector and Metadata Wizard Step 2a - Process Metadata, Select Database Table

2b. Process Metadata – Select Table Columns

  • Select the external table columns for which the wizard will generate property rules.
  • As noted earlier, using nvarchar and nchar column types in MS SQL Server caused the mapping to fail (i.e. such columns would not show up on the below form).

Connector and Metadata Wizard Step 2b - Process Metadata, Select Table Columns

2c. Process Metadata – Select SQL Operations

  • Select for which SQL operations the wizard will generate activity rules.

Connector and Metadata Wizard Step 2c - Process Metadata, Select SQL Operations

2d. Process Metadata – Select Browse Criteria

  • When "Browse the database" is selected in the previous step, this step allows to specify the columns used for querying the external table.
  • All columns were selected here using the "Select All" link.

Connector and Metadata Wizard Step 2d - Process Metadata, Select Browse Criteria

2e. Process Metadata – Map Parameter Values

  • This step shows the activities that will be created and the mapping between input parameters and external table columns.
  • The Wizard-generated activity input parameters etc. can be modified later if needed.

Connector and Metadata Wizard Step 2e - Process Metadata, Select Browse Criteria

3. Review and Save

  • The last step shows the class for the external table mapping, here it is PGX-FlightReservation-Int-Flights, and the associated property rules.
  • The Wizard-generated activities will be located in the PGX-FlightReservation-Work class.
  • Click on the Finish button to run the Wizard.

Connector and Metadata Wizard Step 3 - Review and Save

Wizard Summary

  • Once finished, all created rules and the associated rule set name- and version will be shown.
  • Here, the rule set containing the Wizard-generated rules is FlightReservationInt:01-01-01.

Connector and Metadata Wizard Step 4 - Summary

Review Generated Rules

  • The Application Explorer can be used to review and open the generated rules.
  • PGX-FlightReservation-Int contains the generated properties and a stub data transform.

Application Explorer, view generated property rules

  • Technical > Activity under PGX-FlightReservation-Work contains the generated stub activities for accessing the external table.

Application Explorer, view generated activity rules

  • The activity rules can now be used to access the external table using these Pega 7 methods:
Obj-Browse – to query the database table
Obj-Filter – to filter results of Obj-Browse
Obj-Save – to update and save a record
Obj-Delete – to delete loaded record
Obj-Delete-By-Handle – to obtain a record by ID and then delete it
Obj-Save-Cancel – to cancel the most recent uncommitted Obj-Save

  • Open the wizard-generated activity BrowseFlights and click on the Parameters tab.
  • The wizard may create unnecessary parameters, e.g. that only apply to numeric data types, where a range can be provided (e.g. to search for flights with prices between $500 and $1000).
  • Ranges for text types don’t make sense. Unnecessary parameters can be removed as needed.
  • The refactored Parameters page of the BrowseFlights activity is shown below.

Activity BrowseFlights, view parameters

  • By default, there is one entry on the Pages & Classes form. The pyTempListPage page will hold the results of Obj-Browse. Note that pyTempListPage applies to class Code-Pega-List.

Activity BrowseFlights, view Pages and Classes

  • The Steps page shows the 4 wizard-generated steps, including the invocation of Obj-Browse.
  • Step 2 uses the method Show-Page to display the Obj-Browse results as a XML page.
  • For unit testing, uncomment step 2.
  • Step 3 uses Page-Rename to use the targetPage input parameter for the results page (see When rule to check if targetPage parameter is set, if not step is skipped).

Activity BrowseFlights, view Steps and uncomment Show-Page

  • Expand the first step to view the parameters for the Obj-Browse method.
  • The MaxRecords parameter is set to 100 as a best practice. If left blank, up to 10,000 records will be returned by Obj-Browse, creating a potential performance problem.
  • The UseLightWeightList parameter is checked as a best practice, as it may reduce memory requirements during processing. See the PDN article About lightweight lists for more information.

Activity BrowseFlights, Obj-Browse method parameters

  • The Obj-Browse method has a list of query fields that will be used for selecting records. Use the check box to indicate what fields will be used to match records.
  • In the below screen shot, the selection will result in a SQL WHERE clause similar to this:
WHERE (fromAirport = param.fromAirport) AND (price >= param.fromPrice)
AND (price <= param.toPrice) ORDER BY price

Activity BrowseFlights, Browse-Obj query field selection

  • Run the BrowseFlights activity by clicking on Actions > Run in the Designer Studio.
  • A new window will open. It allow to set values for the activity’s input parameters.
  • Here, all flights from San Francisco (SFO) that cost between $500 and $3,000 are selected.

Activity BrowseFlights, Run and show input parameter page

  • Run the BrowseFlights activity by clicking on the Run button.
  • A new window will show the results of the query. In this example, 2 flights matched the query.
  • The SQL prepared statement is shown in the pxSQLStatementPost node in the pagedata XML.

Activity BrowseFlights, Show-Page XML output of query results

  • The node pxResults of type PageList contains the 2 flight records, ordered ascending by price.
  • Each item in pxResults is a single page of PGX-FlightReservation-Int-Flights.

The BrowseFlights activity can now be used in a Pega 7.1.9 application to e.g. populate a data page using its Load Activity. The other activities for inserting, updating and deleting data can be used in a similar fashion. For related examples on how to connect to external MySQL and Oracle databases, see the below posts on this blog.

Related Posts

Example for Accessing External MySQL Database from Pega 7 PRPC

This post shows how data can be accessed in Pega 7 from an external MySQL database using the Connector and Metadata Accelerator. This wizard will generate the necessary activity rules for accessing the external MySQL DB table and for mapping input parameters and query results.

  • For this example, the MySQL Community Server 5.7.12 for Windows x64 was used.
  • The MySQL DB Server can be downloaded from the MySQL Community Server website.
  • In addition, the MySQL Workbench, a MySQL development and administration tool was used.
  • It can be downloaded for free from the MySQL Workbench website.


  1. Pega 7 Setup Used in this Example
  2. MySQL DB Server Configuration and Table Used in this Example
  3. Configuration of Connection to MySQL Server in Pega 7
  4. Creating a new Database Instance in Pega 7 for MySQL JDBC Access
  5. Running the Pega 7 Connector and Metadata Accelerator
  6. Browse the External MySQL Table with an Activity Rule

Related Posts

  • Pega 7.1.6 was used as a Personal Virtual Server (PVS) installation with the VMWare Player as per the Downloading the Exercise System section of the SAE I (7.1) and SSA (7.1) courses provided by Pega Academy.
  • 64-bit Windows 7 was used as the host operating system (running the VMWare Player).
  • The virtual machine’s network adapter was configured to use NAT (used to share the host’s IP address).

VMWarePlayer Virtual Machine Network Settings NAT Share Host IP Address

The MySQL Server is installed on the Windows host operating system. The Pega 7 platform is running on the virtual machine. It is therefore necessary to make sure that the two systems can communicate with each other over the network. The host’s IP address can be looked up by running ipconfig from the Windows command line. In this case the host’s address is

After starting the virtual machine, the command line window of the VMWare Player can be used to lookup the IP address of the virtual machine and to ping the Windows host machine to confirm network connection. Execute:

  • ifconfig – In this case, the virtual machine has the address
  • ping to confirm that the Pega 7 platform can reach the Windows host system on which the MySQL server will run.

VMWare command line ifconfig and ping to MySQL host machine

  • Also, confirm that the Windows host system can reach the virtual machine by executing ping from a Windows command line.

Windows command line ping Pega 7 PRPC virtual machine

For this post, the MySQL Community Server is used to host a database that represents a product catalog. The database has one table called product_catalog and it has the following five columns:

idint(11)unsigned, primary key, not nullable, auto-increment
namevarchar(45)not nullable
category – enum('electronics', 'books', 'hardware')not nullable
unit_price – decimal(6, 2)not nullable
description – varchar(45)nullable

MySQL product_catalog table structure

  • The MySQL database server is installed to run as a Windows service. To access the server from the MySQL Workbench, the following connection parameters are used:
host name: localhost(MySQL Workbench is running on the same Windows host machine)
port: 3306(default MySQL server port)
username: rootnot nullable
password: *****root password was set during MySQL server installation
  • The MySQL Workbench can be used to create the table and to insert records. For this post, the following 9 rows were inserted into the product_catalog table with the MySQL Workbench.

MySQL product_catalog table data

  • In order to connect from Pega 7 PRPC to the MySQL server, it is highly recommended to create a dedicated user. The MySQL Workbench or the command line can be used for this task.
  • In the MySQL Workbench, click on Users and Privileges and then on the Add Account button.
  • Complete the form and specify the username and password.
  • Keep the default values for Authentication Type (Standard) and Limit to Hosts Matching (%).

MySQLWorkbench Add Account under Users and Privileges

  • Navigate to the Schema Privileges tab and click on the button New Entry. In the dialog window, select the correct schema from the dropdown.
  • Alternatively, All Schema (%) can be used to give the user access to all schemas. Click OK to close the Schema Privilege Definition dialog.

MySQLWorkbench Add Account New Schema Privilege Definition

  • The Schema Privileges tab should show the new entry and clicking on the entry allows to set specific Object Rights such as executing SELECT, INSERT and UPDATE.

MySQLWorkbench Add Account Schema Privileges Tab

  • For the example in this post, only SELECT is required. Click on the Apply button to save the changes.

As a prerequisite for running the Connector and Metadata Accelerator, a Database Instance needs to be created in PRPC. The Database instance will contain the JDBC connection information necessary for PRPC to establish a connection. This setup can be divided into 3 steps:

(a) Download the MySQL JDBC Driver

(b) Copy the MySQL JDBC Driver to PRPC System

  • The MySQL JDBC driver JAR file needs to be copied to the PRPC system. FTP can be used.
  • See FTP Connect to Pega 7 System for Private Virtual Server Installations for details.
  • Copy the mysql-connector-java-5.1.38-bin.jar file to the prweb/WEB-INF/lib folder.
  • Here (Pega 7.1.6 installed on VMWare as PDN exercise system), the full path of the folder is:
  • It may be required to change the access permissions of the WEB-INF/lib directory.
  • The VMWare console can be used to do that by executing the command: sudo chmod 777 lib

Use VMWarePlayer command line to run chmod on WEB-INF lib folder

  • Once the JDBC driver has been copied to the WEB-INF/lib directory, it should look like this:

FileZilla prweb WEB-INF lib Folder with MySQL JDBC Driver Present

(c) Configure PRPC with prconfig.xml

  • The prconfig.xml file needs to be modified to make the MySQL JDBC driver available to PRPC.
  • Use the VMWare console to access the file system of the PRPC instance and navigate to:
  • This folder contains the prconfig.xml file. Change the file permissions by executing the command:
sudo chmod 777 prconfig.xml
  • The file needs to be edited to add an entry to specify the MySQL JDBC driver class.
  • Open the file in the vi editor with vi prconfig.xml and add the line:
<env name="database/drivers" value="com.mysql.jdbc.Driver" />
  • …to specify the MySQL JDBC driver class.

Use VMWarePlayer to run vi to edit PRPC prconfig XML file to specify MySQL JDBC driver class

(d) Restart Pega PRPC

After modifying the prconfig.xml file, it is necessary to restart the Pega 7 PRPC application. This can be accomplished by:

Before running the Connector and Metadata Accelerator to configure access to an external MySQL table, it is necessary to create a new Database instance in Pega 7 PRPC that encapsulates the JDBC connection to the external MySQL DB server.

  • In the Designer Studio, navigate to Records > SysAdmin > Database.

Pega PRPC 7 DesignerStudio Navigation to Records SysAdmin Database

  • In the Instances of Database view, click on the +Create button to start the process of creating a new database instance.

Pega PRPC 7 DesignerStudio View Instances Of Database

  • This will open the Create Database form. Enter a description and a name for the database instance and click on the Create and open button.
  • This will save the new database instance and open it in edit mode for further configuration.

Pega PRPC 7 DesignerStudio Create Database

  • On the Database tab of the database instance, specify use JDBC URL listed below in the How To Connect dropdown.
  • Enter the correct MySQL JDBC URL in the JDBC URL text field. In this case, it is:
  • Where is the IP address of the Windows host system on which the MySQL server is running and product_catalog is the name of the schema to access.
  • Specify the username and password of the MySQL user account that was created in step 2. In this case the username is prpc.

Pega PRPC 7 DesignerStudio Edit Database Database Tab

  • Click on the Test Connection button to validate the configuration. A new dialog should show a successful connection status message:

Pega PRPC 7 DesignerStudio Edit Database Test Database Connection Success

  • Note: In case of connection errors, refer to earlier sections on network configuration and MySQL server setup. Below are some possible error scenarios and how to approach fixing them.

ERROR: No Suitable Driver Found

  • Make sure that the MySQL JDBC driver file mysql-connector-java-5.1.38-bin.jar is copied to the /WEB-INF/lib folder on the PRPC system and that the prconfig.xml has been modified as described in section 3.

Pega PRPC 7 DesignerStudio Edit Database Test Database Connection No suitable driver found for jdbc:mysql

ERROR: Communications Link Failure

  • This error is caused most likely by a network connection problem. Make sure the IP address of the MySQL server host machine is correct and reachable from the Pega 7 PRPC host system.
  • In this case Pega 7 is running on a virtual machine using the VMWare player. See section 1 for verifying network connectivity between the virtual machine and the MySQL DB Server host.

Pega PRPC 7 DesignerStudio Edit Database Test Database Connection Communications Link Failure The last package sent successfully to the server was 0 milliseconds ago

ERROR: Host… not Allowed to Connect to MySQL Server

  • Refer to section 2 and make sure that the MySQL user account (here prpc) used by Pega 7 is configured properly.
  • Check if it has Limits to host matching set to % to allow all remote hosts to connect to the MySQL server instance. Note that, by default, the root user does not have remote access.

Pega PRPC 7 DesignerStudio Edit Database Test Database Connection Host is Not Allowed To Connect To this MySQL Server

  • After configuring the database instance and successfully testing the connection, save the record and reload the Instances of Database view.

Pega 7 PRPC Instances Of Database MySQL

  • The new external MySQL database instance should now appear in the list as shown in the screen shot above. Here, the database instance is named MySQLProductCatalog.

  • Navigate to Designer Studio > Integration > Connectors > Create Other Integration to open the Pega 7 Connector and Metadata Accelerator.

Pega 7 PRPC DesignerStudio Navigation Integration Connectors Create Other Integration

1. Choose Purpose

  • For connecting to an external database, the Purpose must be set to Generate Connector Rules and the Metadata Type must be set to SQL.
  • Select an appropriate rule set name, ideally an integration rule set, and the rule set version.
  • The Base Class should be a class derived from the Data- class.
  • The Connector Activity Class should be a class that is derived from the Work- class.
  • For more information refer to the Pega 7 Help entry titled About generating connector rules.

Pega 7 PRPC Connector And Metadata Accelerator Choose Purpose

  • Click on the Next button to continue.

2a. Process Metadata – Select Database Table

  • On the Select Database Table form, select the database instance that was created in section 4 and specify the Schema Name.
  • Here, the schema name is product_catalog (see section 2).
  • Once the schema name is entered, the form will show all tables in an auto-complete control.
  • Here, the Table Name is set to products (see section 2).

Pega 7 PRPC Connector And Metadata Accelerator Choose Purpose ProcessMetadata Select Database Table

  • Click on Next to continue.

2b. Process Metadata – Select Table Columns

  • Check-mark the required table columns, in this case all available columns are selected.

Pega 7 PRPC Connector And Metadata Accelerator Choose Purpose ProcessMetadata Select Table Columns

  • Click on Next to continue.

2c. Process Metadata – Select SQL Operations

  • Select the SQL operations that are needed for the specific application use case.
  • In this case, all operations are selected and for each one the wizard will create an activity rule.

Pega 7 PRPC Connector And Metadata Accelerator Choose Purpose ProcessMetadata Select SQL Operations

  • Click on Next to continue.

2d. Process Metadata – Select Browse Criteria

  • If Browse the database was checked in the previous form, the Select Browse Criteria form appears.
  • It is used to select specific columns which PRPC can use to query the external MySQL table.

Pega 7 PRPC Connector And Metadata Accelerator Choose Purpose ProcessMetadata Select Browse Criteria

  • Click on Next to continue.

2e. Process Metadata – Map Parameter Values

  • The Map Parameter Values form does not have to be changed for this example, it allows to specify the input parameters of the activity rules (browse, update etc.) that will be generated for each SQL operation. These input parameters can be changed easiliy later.

Pega 7 PRPC Connector And Metadata Accelerator Choose Purpose ProcessMetadata Map Parameter Values

  • Click on Next to continue.

3. Review and Save

  • The Review and Save form, lists all rules that will be generated and modified when the wizard runs.
  • Note that a data class will be created that derives from Data-, using the table name that was specified earlier.
  • In addition, all activity rules that will be created for the selected SQL operations are listed here.

Pega 7 PRPC Connector And Metadata Accelerator Review And Save

  • Click on Finish to complete the setup and to let the wizard generate the required rules.
  • A final confirmation screen will be shown once the wizard has completed generating the rules.

Pega 7 PRPC Connector And Metadata Accelerator Confirmation

  • Here, 13 rules were generated, including 4 activity rules for browse, insert, update and delete operations and 5 property rules for mapping the columns of the products table.
  • Click on Close to complete the setup process and to close the wizard.

  • The auto-generated Browseproducts activity can now be unit tested to ensure that PRPC can successfully retrieve data from the external MySQL products table.
  • Open the rule and remove unnecessary input parameters. For this example, only browsing by category is required. So, the other input parameters can be deleted from this activity or the required flag can be set to No.
  • Note that the wizard created from and to parameters for each table column. Some parameters may not be applicable and can be removed.

Activity Browseproducts Parameters

  • Defining from and to parameters only makes sense for numeric table columns, where a range is provided to query the table (e.g.: search products where unit price is between $0.00 and $100.00).
  • Here, the list of input parameters of the Browseproducts activity was reduced as shown below.

Activity Browseproducts Parameters Short Parameter List

  • Switch to the Steps tab and expand the first step that calls the Obj-Browse method.
  • Configure the selected fields as needed and set the CONDITION to either Value Only or use Is Equal for a comparison to an input parameter value. Value Only means that the field will not be used for querying but that it will be included in the search results.
  • For testing, remove the comment (//) from the step which calls Show-Page, to Show the temporary list page of query results. When the activity is executed, this will result in a popup window showing the SQL query results in XML format.

Activity Browseproducts Parameters Steps Obj-Browse Method

  • Click on Save to commit the changes to the activity.
  • The activity can be run by clicking on Actions > Run.
  • In the activity execution window, enter the value for the input parameter to query by, in this case the input parameter is category and only table rows where the category matches electronics should be returned (see Is Equal condition on the steps page of the activity).
  • Click on the Execute button to run the browse activity.

Activity Browseproducts Parameters Run Enter Parameters

  • A new dialog window will open and show the query results in XML format.
  • The XML output will contain the total number of rows retrieved from the table, the actual SQL query string that was executed against the external MySQL table and the result data.
  • The node pxResults contains the query results. Each entry is of the type PXC-OrderCat-Data-products.
  • In this case, 4 products, where the category matches electronics, were retrieved from the products table on the MySQL server.

Activity Browseproducts Run pagedata pxResults

  • The activity rule can now be used in a Pega 7 application as a data source for e.g. populating a drop-down control or a repeating grid on a UI section.