How to expose PostgreSQL tables in LiveView

How to expose PostgreSQL tables in LiveView

book

Article ID: KB0073585

calendar_today

Updated On:

Products Versions
TIBCO Live Datamart 10.x

Description

What configuration is required to expose PostgreSQL tables in LiveView?

Resolution

In your jdbc HOCON configuration, set the following:
 jdbcDataSources = { 	sample = { 	       serverURL = "jdbc:postgresql://localhost:5432/postgres?currentSchema=public" 	       driverClassName = "org.postgresql.Driver" 	       userName = "postgres" 	       password = "P@ssw0rd!" 	} }
In pom.xml, be sure to add the PostgreSQL JDBC driver as a Maven dependency:
 <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> <dependency>     <groupId>org.postgresql</groupId>     <artifactId>postgresql</artifactId>     <version>42.2.20</version> </dependency>
In your LiveView project under src/main/liveview, add a LiveView table configuration for each JDBC table you wish to expose. For example..
 <?xml version="1.0" encoding="UTF-8"?> <liveview-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.streambase.com/schemas/lvconf/">   <external-server-connection id="Devices" type="jdbc-tables">     <parameters>       <parameter key="dataSourceRefName">sample</parameter>     </parameters>     <mappings>       <mapping selector="devices" formatter="%s"/>     </mappings>     <retry-parameters/>   </external-server-connection> </liveview-configuration>
The above configuration ( Devices.lvconf) exposes the PostgreSQL table named devices as a LiveView table of the same name. The JDBC data source name ( sample) matches the name shown in the jdbcDataSources configuration above.

The devices table in the postgres database will now be exposed to LiveView clients, such as the Studio LiveView Tables view:
User-added image

Issue/Introduction

Discusses how to expose PostgreSQL tables in LiveView using a jdbc data source configuration.

Additional Information