![]() |
VOOZH | about |
There are a vast number of PostgreSQL clients available on the Internet. From standard Drivers to BI and Analytics tools, PostgreSQL is a popular interface for data access. Using our JDBC Drivers, you can now create PostgreSQL entry-points that you can connect to from any standard client.
To access SAS Data Sets data as a PostgreSQL database, use the CData JDBC Driver for SAS Data Sets and a JDBC foreign data wrapper (FDW). In this article, we compile the FDW, install it, and query SAS Data Sets data from PostgreSQL Server.
To connect to SAS Data Sets as a JDBC data source, you will need the following:
Driver class:
cdata.jdbc.sasdatasets.SASDataSetsDriver
Set the following connection properties to connect to your SAS DataSet files:
While the driver is capable of pulling data from SAS DataSet files hosted on a variety of cloud data stores, INSERT, UPDATE, and DELETE are not supported outside of local files in this driver.
Set the Connection Type to the service hosting your SAS DataSet files. A unique prefix at the beginning of the URI connection property is used to identify the cloud data store and the remainder of the path is a relative path to the desired folder (one table per file) or single file (a single table). For more information, refer to the Getting Started section of the Help documentation.
For assistance in constructing the JDBC URL, use the connection string designer built into the SAS Data Sets JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.sasdatasets.jar
Fill in the connection properties and copy the connection string to the clipboard.
👁 Using the built-in connection string designer to generate a JDBC URL (Salesforce is shown.)A typical JDBC URL is below:
jdbc:sasdatasets:URI=C:/myfolder;
The Foreign Data Wrapper can be installed as an extension to PostgreSQL, without recompiling PostgreSQL. The jdbc2_fdw extension is used as an example (downloadable here).
ln -s /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server/libjvm.so /usr/lib/libjvm.so
make install USE_PGXS=1
After you have installed the extension, follow the steps below to start executing queries to SAS Data Sets data:
CREATE EXTENSION jdbc2_fdw;
CREATE SERVER SASDataSets FOREIGN DATA WRAPPER jdbc2_fdw OPTIONS ( drivername 'cdata.jdbc.sasdatasets.SASDataSetsDriver', url 'jdbc:sasdatasets:URI=C:/myfolder;', querytimeout '15', jarfile '/home/MyUser/CData/CData\ JDBC\ Driver\ for\ Salesforce MyDriverEdition/lib/cdata.jdbc.sasdatasets.jar');
CREATE USER MAPPING for postgres SERVER SASDataSets OPTIONS ( username 'admin', password 'test');
postgres=# CREATE FOREIGN TABLE restaurants ( restaurants_id text, restaurants_name text, restaurants_borough numeric) SERVER SASDataSets OPTIONS ( table_name 'restaurants');
postgres=# SELECT * FROM restaurants;
Download a free trial of the SAS Data Sets Driver to get started:
Download NowLearn more:
👁 SAS Data Sets IconRapidly create and deploy powerful Java applications that integrate with SAS Data Sets.