Connecting a PostgreSQL Database
In this tutorial you are connecting to an external data repository using an access. An access is a bridge between a model and the data stored in a specific repository. The repository you want to connect is an empty PostgreSQL database.
On this page
Steps
To connect a PostgreSQL database, you must perform the following steps:
Prerequisites
A running PostgreSQL database. In the context of this procedure it does not matter if use a local or a dockerized PostgreSQL installation. In this procedure, we assume the username for the database is cortex, the password is also cortex, and the database runs on port 5432. We will also use the UserModel as the metamodel for your access.
Creating a PostgreSQL Connection
To create a PostgreSQL connection:
- 
Download a JDBC connector for PostgreSQL and place the connector .jarfile in the<TRIBEFIRE_INSTALLATION_DIRECTORY>/tribefire/host/libdirectory.For PostgreSQL connector download page, see: JDBC Home. 
- 
Start the tribefire Server and open Control Center. If your tribefire Server was running when you copied the connector file, you must restart it. 
- 
In Control Center, on the Workbench panel, click the Connections entry point, and click New. 
- 
Select the HikariCpConnectionPoolentry and configure it as follows:Name Value Description externalId myPostgreSQLConnection.localExternal ID of the connection name myPostgreSQLConnectionInternal name of the connection 
- 
In the same modal window, next to the connectionDescriptorlabel, click Assign. New view is displayed.
- 
In the DatabaseConnectionDescriptor view, select the GenericDatabaseConnectionDescriptor, and configure it as follows:Name Value Description driver org.postgresql.DriverClass name of the driver password cortexPassword for the database schema you are connecting to. url jdbc:postgresql://localhost:5432/cortexURL to the database schema. user cortexUser you use to connect to the database. 
- 
In the DatabaseConnectionDescriptor view, click Apply. You can see that your database connection descriptor is added to the connection. 
- 
In the connection view, click Apply. Your new myPostgreSQLConnection is displayed in a new tab. Click the Commit button. 
- 
Right-click your new connection and click Deploy. Your connection is deployed. 
- 
Right-click your deployed connection and click Test Connection. If you did everything correctly, the Connection successfully tested message is displayed at the top of the screen. 
Continue with Creating a PostgreSQL Access.
Creating a PostgreSQL Access
To create a PostgreSQL Access:
- 
In Control Center, on the Workbench panel, click Custom Accesses, and then click New. 
- 
Select HibernateAccess and configure it as follows: Name Value Description externalId myPostgreSQLAccess.localExternal ID of the access name myPostgreSQLAccessInternal name of the access metamodel UserModelThe model this access operates on. 
- 
In the same modal window, next to the connector label, click Assign. New view is displayed. 
- 
In the DatabaseConnectionPool view, select the myPostgreSQLConnection and click Finish. You can see that your database connection descriptor is added to the connection. 
- 
In the connection view, click Apply. Your access is opened in a new tab. Click Commit. 
- 
Right-click your access and click Deploy. Your new access is deployed and ready to be queried. 
- 
Continue with Testing a PostgreSQL Access 
Testing a PostgreSQL Access
To test the PostgreSQL access:
- In Control Center, on the Workbench panel, click Custom Accesses. The Custom Accesses tab is displayed.
- Right-click your myPostgreSQLAccess and select Switch To. Explorer opens.
- In Explorer, locate the Quick Access... search box at the top of the page. In the search box, type User and select the Usertype from the drop-down list. A new User tab is displayed.
- Notice there is no data in the new User tab. That is because there are no records of the type Userin your PostgreSQL database. Time to change that.
- On the User tab, click New. A new modal window is displayed. In the modal window, provide the value for the nameparameter.
- In the modal window, click Apply. The modal window disappears and Explorer is displayed again. In Explorer, click Commit.
- In Explorer, on the Action Bar, click Refresh. The Userinstance you added directly to the database schema is visible and available in tribefire.