<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/tag/java/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Thu, 11 Dec 2025 12:34:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.4</generator>

<image>
	<url>https://zappysys.com/blog/wp-content/uploads/2023/01/cropped-zappysys-symbol-large-32x32.png</url>
	<title>Java Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/java/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Connect to Infor Compass using JDBC Driver in ODBC Apps (e.g. SQL Server, Power BI, Excel, Informatica)</title>
		<link>https://zappysys.com/blog/connect-infor-compass-jdbc-driver-odbc-apps-power-bi-excel-informatica-sql-server/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Tue, 13 Sep 2022 22:04:31 +0000</pubDate>
				<category><![CDATA[JDBC Bridge Driver]]></category>
		<category><![CDATA[infor]]></category>
		<category><![CDATA[infor datalake]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[odbc]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=9787</guid>

					<description><![CDATA[<p>Introduction In this blog post you will learn how to use Infor Compass JDBC driver in ODBC Apps (i.e. non-JAVA apps) such as Power BI, Excel, Informatica and many more listed here using JDBC-ODBC Bridge Driver. In other words, if you like to use Infor Compass data in your App / Programming language and App [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/connect-infor-compass-jdbc-driver-odbc-apps-power-bi-excel-informatica-sql-server/">Connect to Infor Compass using JDBC Driver in ODBC Apps (e.g. SQL Server, Power BI, Excel, Informatica)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2022/09/Infor_logo-300x300.png"><img decoding="async" class=" wp-image-9795 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2022/09/Infor_logo-300x300.png" alt="" width="139" height="139" srcset="https://zappysys.com/blog/wp-content/uploads/2022/09/Infor_logo-300x300.png 300w, https://zappysys.com/blog/wp-content/uploads/2022/09/Infor_logo-300x300-150x150.png 150w" sizes="(max-width: 139px) 100vw, 139px" /></a>In this blog post you will learn how to use <a href="https://docs.infor.com/inforos/2021.x/en-us/datafabrug/default.html?helpcontent=aky1631199546535.html" target="_blank" rel="noopener">Infor Compass JDBC driver</a> in ODBC Apps (i.e. non-JAVA apps) such as Power BI, Excel, Informatica and <a href="https://zappysys.com/api/integration-hub/jdbc-connector/" target="_blank" rel="noopener">many more listed here</a> using <a href="https://zappysys.com/products/odbc-powerpack/odbc-jdbc-bridge-driver/" target="_blank" rel="noopener">JDBC-ODBC Bridge Driver</a>. In other words, if you like to use Infor Compass data in your App / Programming language and App doesnt support using JDBC Driver Infor Provides then this article is for you. ZappySys has created a Bridge Driver which can translate ODBC calls to JDBC making it possible to call any JDBC driver in non Java Apps (i.e. ODBC Apps) written in languages like C++ / C#  / Python etc.</p>
<p>So lets get started.</p>
<div class="content_block" id="custom_post_widget-9166"><h2>Requirements</h2>
In order to access API data inside your App using ODBC Driver you will need to make sure following requirements are met.
<ol>
 	<li>Download and Install <a href="https://zappysys.com/products/odbc-powerpack/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a> (This includes XML / JSON / REST API and few other drivers for SQL Server and ODBC connectivity in tools like Excel, Power BI, SSRS)</li>
</ol></div>
<h2>Download Infor Compass JDBC Driver and ionapi file</h2>
<p>Check below links to download and configure Infor Compass JDBC.</p>
<ol>
<li><a href="https://docs.infor.com/inforos/2021.x/en-us/datafabrug/default.html?helpcontent=aky1631199546535.html">Download Infor Compass JDBC Driver (*.jar file)</a></li>
<li><a href="https://docs.infor.com/inforos/2021.x/en-us/datafabrug/default.html?helpcontent=daa1631199546835.html">Extract Driver</a> files to local folder</li>
<li><a href="https://docs.infor.com/inforos/2021.x/en-us/datafabrug/default.html?helpcontent=qxg1631199547147.html">Download and Configure *.ionapi file</a> &#8211; <strong>Infor Compass JDBC Driver.ionapi</strong> file (Placed in same directory where JDBC driver is saved)</li>
</ol>
<h2>Setup JDK (Java Runtime)</h2>
<p>Before you start using ZappySys JDBC Bridge Driver, we need to install JAVA Runtime (JRE) or Java Development Kit (JDK).</p>
<p>We recommend installing <strong>JDK21 or higher</strong> (other JRE / JDK version(s) might work too).</p>
<p>There are several ways to get Java Runtime Installer, but we recommend from following link. Skip below steps if you have JAVA Runtime already installed.</p>
<ol>
<li>Download JDK 21 (i.e. Amazon Corrento OpenJDK distribution). <a href="https://docs.aws.amazon.com/corretto/latest/corretto-21-ug/downloads-list.html" target="_blank" rel="noopener">Listed here</a><br />
<strong>Direct Download Link</strong>:  <a href="https://corretto.aws/downloads/latest/amazon-corretto-21-x64-windows-jdk.msi" target="_blank" rel="noopener noreferrer">amazon-corretto-21-x64-windows-jdk.msi</a></li>
<li>Run the downloaded msi installer file</li>
<li>After it&#8217;s installed, you can confirm Java version by running the following command line. It will show<br />
<pre class="crayon-plain-tag">java.exe -version</pre>
<strong>Sample Output</strong><br />
<pre class="crayon-plain-tag">openjdk version "21.0.7" 2025-04-15 LTS
OpenJDK Runtime Environment Temurin-21.0.7+6 (build 21.0.7+6-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.7+6 (build 21.0.7+6-LTS, mixed mode, sharing)</pre>
</li>
</ol>
<p>&nbsp;</p>
<h2>Download Infor JDBC Driver / Generate ionapi Credentials File</h2>
<p>To access infor Data using their official JDBC Driver you will need to do 2 things</p>
<ol>
<li>Download Infor JDBC Driver locally</li>
<li>Create ionapi file locally</li>
</ol>
<p><a href="https://docs.infor.com/inforos/2021.x/en-us/datafabrug/default.html?helpcontent=qxg1631199547147.html" target="_blank" rel="noopener">Read this link</a> for more information</p>
<p>Here is the video Tutorial</p>
<a href="https://zappysys.com/blog/connect-infor-compass-jdbc-driver-odbc-apps-power-bi-excel-informatica-sql-server/"><img decoding="async" src="https://zappysys.com/blog/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FyipG8w6qQPg%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p>
<p>&nbsp;</p>
<h2>Create ODBC DSN for Infor Compass JDBC Driver</h2>
<p>In this section, you will learn <i>how to Configure ODBC DSN</i>. Later on, this DSN can be used to use ZappySys Driver. ODBC DSN can be stored at Machine Level (for all users) or the Current User Level. In this case, we are going to load data into Microsoft Excel from PostgreSQL Storage using ZappySys JDBC Bridge ODBC Driver.</p>
<p>&nbsp;</p>
<ol>
<li>Type <strong>odbcad32.exe</strong> in your search box and launch the DSN Config utility.<br />
<img decoding="async" class="figureimage" src="https://zappysys.com/blog/wp-content/uploads/2018/03/odbc-data-source-64-bits.png" /></li>
<li>If you want access for yourself then stay on User DSN Tab. If you want to grant access to other users, then go to the System DSN tab. For <a href="https://zappysys.com/onlinehelp/odbc-powerpack/scr/odbc-integration-programming-tsql.htm">SQL Server Integration</a> go to the System Tab and add a new System DSN rather than User DSN. Click the New button.<br />
<img decoding="async" class="figureimage" title="ZappySys ODBC Driver - Open UI" src="https://zappysys.com/onlinehelp/odbc-powerpack/scr/images/zappysys-odbc-driver-open-ui.png" alt="ZappySys ODBC Driver - Open UI" /></li>
<li>From the Driver list Select ZappySys ODBC Driver. For this example, select [ZappySys JDBC Bridge Driver].<br />
<img decoding="async" class="figureimage" title="ZappySys ODBC Driver - Create JDBC Bridge Driver" src="https://zappysys.com/onlinehelp/odbc-powerpack/scr/images/jdbc-driver/jdbc-bridge-driver-create.png" alt="ZappySys ODBC Driver - Create JDBC Bridge Driver" /></li>
</ol>
<p>&nbsp;</p>
<h2>Configure ODBC DSN for Infor Compass Connectivity</h2>
<p>Once you downloaded / extracted JDBC (*.jar) and *.ionapi files and saved them to the local disk you can configure ZappySys JDBC Bridge Driver like the below</p>
<ol>
<li>Create a folder e.g. C:\Infor_Datalake</li>
<li>Extract jdbc driver files in that folder, keep ionapi file in the same folder too (v1.7 will look ionapi file under this folder)</li>
<li>Make sure do not rename <strong>ionapi</strong> file. It must be named as &#8220;<strong>Infor Compass JDBC Driver.ionapi</strong>&#8221;<br />
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">
If you are getting this error (<a href="https://community.zappysys.com/t/the-infor-compass-jdbc-driver-ionapi-file-is-not-found-infor-data-lake-error/142">Infor Compass JDBC Driver.ionapi file is not found</a>) then we suggest you copy ionapi file in the below locations too. If you are not planning to use <a href="https://zappysys.com/api/integration-hub/jdbc-connector/sql-server" target="_blank" rel="noopener">Data Gateway / Linked Server</a> then you can skip ionapi file copy to 3rd location (i.e. <b>ZappySys.TdsServer.WindowsService</b> folder).<br />
<pre class="crayon-plain-tag">C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack\JdbcBridgeDriverX64
C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack\JdbcBridgeDriverX86
C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack\ZappySys.TdsServer.WindowsService</pre>
</div></div></li>
<li>Open ODBC DataSource UI by double clicking the DSN (you created in the previous section).</li>
<li>Enter JDBC Connection String as per this format<br />
<pre class="crayon-plain-tag">jdbc:infordatalake://TENANTNNAME</pre>
</li>
<li>Enter Driver class (Optional).<br />
<pre class="crayon-plain-tag">com.infor.idl.jdbc.Driver</pre>
</li>
<li>Enter User ID and Password is optional so <strong>keep it blank</strong> unless required by driver. Click <strong>Test Connection</strong>
<div id="attachment_9788" style="width: 578px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2022/09/connect-infor-compass-jdbc-odbc-bridge-driver.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-9788" class="wp-image-9788 size-full" src="https://zappysys.com/blog/wp-content/uploads/2022/09/connect-infor-compass-jdbc-odbc-bridge-driver.png" alt="Using Infor Compass JDBC Driver in ODBC Apps via ZappySys JDBC Bridge Driver " width="568" height="546" srcset="https://zappysys.com/blog/wp-content/uploads/2022/09/connect-infor-compass-jdbc-odbc-bridge-driver.png 568w, https://zappysys.com/blog/wp-content/uploads/2022/09/connect-infor-compass-jdbc-odbc-bridge-driver-300x288.png 300w" sizes="(max-width: 568px) 100vw, 568px" /></a><p id="caption-attachment-9788" class="wp-caption-text">Using Infor Compass JDBC Driver in ODBC Apps via ZappySys JDBC Bridge Driver</p></div></li>
<li>Now you can go to Preview Tab and select Table from the dropdown and write query to preview data</li>
</ol>
<h2>Video Tutorial &#8211; ODBC-JDBC Bridge Driver</h2>
<a href="https://zappysys.com/blog/connect-infor-compass-jdbc-driver-odbc-apps-power-bi-excel-informatica-sql-server/"><img decoding="async" src="https://zappysys.com/blog/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FBEJ1HbBZqxY%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p>
<p>&nbsp;</p>
<h2>Connect Infor Compass Datalake in SQL Server (Linked Server)</h2>
<p>So in our previous section, we saw how to connect using ODBC Driver but if you like to access Infor Datalake data in SQL Server then you have to use the Data gateway approach. <a href="https://zappysys.com/api/integration-hub/jdbc-connector/sql-server" target="_blank" rel="noopener">Click here</a> to learn more.</p>
<p>In Data Gateway Driver UI is pretty much the same as ODBC UI except few differences. You also need to configure the Linked server which requires extra steps. The above link is for a generic JDBC Driver but follow Infor Datalake JDBC-specific steps mentioned in the ODBC setup section in this article.</p>
<h2>Troubleshooting Known Errors</h2>
<p>Here in this section, we will discuss some known errors and its workaround.</p>
<h3>The Infor Compass JDBC Driver.ionapi file is not found</h3>
<p>If you get this error you can review <a href="https://community.zappysys.com/t/the-infor-compass-jdbc-driver-ionapi-file-is-not-found-infor-data-lake-error/142">this solution</a></p>
<h3><span class="hljs-selector-tag">Data</span> <span class="hljs-selector-tag">Lake</span> <span class="hljs-selector-tag">is</span> <span class="hljs-selector-tag">not</span> <span class="hljs-selector-tag">available /  Unable to verify trust for server certificate chain</span></h3>
<p>If you get the following error then <a href="https://community.zappysys.com/t/how-to-fix-jbr-error-java-sql-sqlexception-data-lake-is-not-available-unable-to-verify-trust-for-server-certificate-chain-cn-ionapi-inforcloudsuite-com/101">check this link</a> for possible workarounds</p><pre class="crayon-plain-tag">JBR error: java.sql.SQLException: <strong>Data Lake is not available</strong>

at com.infor.idl.jdbc.Driver.connect(Driver.java:422) 
at DbConnection.Init(DbConnection.java:45) 

.......... 
.......... 
<strong>Unable to verify trust for server certificate chain</strong> [CN=mingle-ionapi.inforcloudsuite.com, CN=pa-trusted-ca.noble.loc, CN=noble-SUBCA-CA, DC=noble, DC=loc, CN=ROOTCA-CA, CN=ROOTCA-CA] .......... at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) 
.......... 
..........</pre><p>
<h3>Test Connection Hangs</h3>
<p>This happens if you have not installed the latest Java version (i.e. Java 21 or higher) and you are using the latest JDBC, which doesn&#8217;t support Java8 (i.e. infor-compass-jdbc-2025.06.05.jar)</p>
<p>To fix this issue, uninstall the  older version of Java and install the new Java (e.g. v21 or higher) <a href="https://corretto.aws/downloads/latest/amazon-corretto-21-x64-windows-jdk.msi">from here</a></p>
<h2>Using Infor Compass ODBC-JDBC connection in various apps (e.g. Power BI, Excel, Informatica, SQL Server)</h2>
<p>Once you create ODBC DSN you are ready to test that in any ODBC-compliant apps <a href="https://zappysys.com/api/integration-hub/jdbc-connector/" target="_blank" rel="noopener">listed here</a></p>
<p>If your app is not listed in the above link, then no worries just find the Option to connect to ODBC in your App and use DSN we created in an earlier section.</p>
<div class="content_block" id="custom_post_widget-7051">ZappySys ODBC Drivers built using ODBC standard which is widely adopted by industry for a long time. Which mean the majority of BI Tools / Database Engines / ETL Tools already there will support native / 3rd party ODBC Drivers. Below is the small list of most popular tools / programming languages our Drivers support. If your tool / programming language doesn't appear in the below list, which means we have not documented use case but as long as your tool supports ODBC Standard, our drivers should work fine.

&nbsp;

<img loading="lazy" decoding="async" class="" src="//zappysys.com/images/odbc-powerpack/odbc-powerpack-integration.jpg" alt="ZappySys ODBC Drivers for REST API, JSON, XML - Integrate with Power BI, Tableau, QlikView, QlikSense, Informatica PowerCenter, Excel, SQL Server, SSIS, SSAS, SSRS, Visual Studio / WinForm / WCF, Python, C#, VB.net, PHP. PowerShell " width="750" height="372" />
<table style="valign: top;">
<tbody>
<tr>
<td>
<p style="text-align: center;"><strong>BI / Reporting Tools
Integration</strong></p>
</td>
<td style="text-align: center;"><strong>ETL Tools
Integration
</strong></td>
<td style="text-align: center;"><strong>Programming Languages</strong>
<strong>Integration</strong></td>
</tr>
<tr>
<td>
<ul>
 	<li><a href="https://zappysys.com/blog/howto-import-json-rest-api-power-bi/" target="_blank" rel="noopener">Microsoft Power BI</a></li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-tableau-read-json-soap-xml-csv/">Tableau</a></li>
 	<li><a href="https://zappysys.com/blog/read-rest-api-using-ssrs-reports-call-json-xml-web-service/" target="_blank" rel="noopener">SSRS (SQL Reporting Services)</a></li>
 	<li><a href="https://zappysys.com/blog/qlik-rest-connector-examples-read-json-xml-api/" target="_blank" rel="noopener">QlikView /Qlik Sense</a></li>
 	<li><a href="https://zappysys.com/blog/call-rest-api-in-microstrategy-json-soap-xml/" target="_blank" rel="noopener">MicroStrategy</a></li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-google-sheet-call-appscript-load-json-soap-xml-csv/" target="_blank" rel="noopener">Google Sheet</a></li>
 	<li><a href="https://zappysys.com/blog/import-json-excel-load-file-rest-api/" target="_blank" rel="noopener">Microsoft Excel</a></li>
 	<li><a href="https://zappysys.com/api/integration-hub/rest-api-connector/access?context=connector" target="_blank" rel="noopener">Microsoft Access</a></li>
 	<li>Oracle OBIEE</li>
 	<li>Many more (not in this list).....</li>
</ul>
</td>
<td>
<ul>
 	<li><a href="https://zappysys.com/blog/read-json-informatica-import-rest-api-json-file/" target="_blank" rel="noopener">Informatica PowerCenter</a> (Windows)</li>
 	<li>Informatica Cloud</li>
 	<li>SSIS (SQL Integration Services)</li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-json-sql-server/" target="_blank" rel="noopener">SQL Server</a></li>
 	<li><a href="https://zappysys.com/blog/read-write-rest-api-data-in-talend-json-xml-soap/" target="_blank" rel="noopener">Talend Data Studio</a></li>
 	<li><a href="https://zappysys.com/blog/pentaho-read-rest-api-in-pentaho/" target="_blank" rel="noopener">Pentaho Kettle</a></li>
 	<li>Oracle OBIEE</li>
 	<li>Many more (not in this list).....</li>
</ul>
</td>
<td>
<ul>
 	<li>Visual Studio</li>
 	<li><a href="https://zappysys.com/blog/calling-rest-api-in-c/" target="_blank" rel="noopener">C#</a></li>
 	<li>C++</li>
 	<li><a href="https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/" target="_blank" rel="noopener">JAVA</a></li>
 	<li><a href="https://zappysys.com/blog/set-rest-python-client/" target="_blank" rel="noopener">Python</a></li>
 	<li>PHP</li>
 	<li><a href="https://zappysys.com/blog/call-rest-api-powershell-script-export-json-csv/" target="_blank" rel="noopener">PowerShell</a></li>
 	<li><a href="https://zappysys.com/blog/import-rest-api-json-sql-server/" target="_blank" rel="noopener">T-SQL (Using Linked Server)</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
&nbsp;</div>
<h2>Conclusion</h2>
<p>In this post we saw how easy it is to use the Infor Compass JDBC driver in any non-JAVA app in a few steps. <a href="https://zappysys.com/products/odbc-powerpack/odbc-jdbc-bridge-driver/">Click here to download</a> ZappySys JDBC Bridge Driver.</p>
<p>The post <a href="https://zappysys.com/blog/connect-infor-compass-jdbc-driver-odbc-apps-power-bi-excel-informatica-sql-server/">Connect to Infor Compass using JDBC Driver in ODBC Apps (e.g. SQL Server, Power BI, Excel, Informatica)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to connect Java to REST API (JSON / SOAP XML)</title>
		<link>https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/</link>
		
		<dc:creator><![CDATA[ZappySys Team]]></dc:creator>
		<pubDate>Sun, 22 Jul 2018 18:50:09 +0000</pubDate>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[ODBC Gateway]]></category>
		<category><![CDATA[ODBC PowerPack]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rest api]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=4478</guid>

					<description><![CDATA[<p>Introduction In this new article, we will see how to connect Java to REST API using a simple connector. This ODBC driver allows connecting to REST API or a local file in Java using SQL queries. If you are familiar with SQL, you can easily access to REST API or JSON using simple SQL queries. This article mainly [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/">How to connect Java to REST API (JSON / SOAP XML)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Java.png"><img loading="lazy" decoding="async" class=" wp-image-4482 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Java.png" alt="Java logo used" width="61" height="61" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Java.png 256w, https://zappysys.com/blog/wp-content/uploads/2018/07/Java-150x150.png 150w" sizes="(max-width: 61px) 100vw, 61px" /></a>In this new article, we will see how to connect Java to REST API using a simple connector. This ODBC driver allows connecting to REST API or a local file in Java using SQL queries. If you are familiar with SQL, you can easily access to REST API or JSON using simple SQL queries. This article mainly focus on JSON based REST API but techniques listed in this article is almost same for XML based API (e.g. SOAP Web Services).</p>
<h2>Requirements</h2>
<ol>
<li>First of all, we will require the <a href="https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server?view=sql-server-2017" target="_blank" rel="noopener">JDBC Driver for SQL Server</a>.</li>
<li>Secondly, we will require <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a>.</li>
<li>Also, we will require a Java IDE. We will use <a href="https://netbeans.org/community/releases/74/index.html" target="_blank" rel="noopener">Java NetBeans</a> for this.</li>
</ol>
<h2>Getting started</h2>
<p>First of all, we will create an ODBC connection with a Gateway to the SQL Server connector and then we will connect with Java code.</p>
<h3>Add ZappySys ODBC Driver to connect to REST API</h3>
<p>The ZappySys JSON Driver allows connecting to different resources like JSON files, REST API, OData, etc.</p>
<ol>
<li>First of all, in the ODBC Data Source Administrator, press add to add a new System Data Source:
<div id="attachment_4484" style="width: 600px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4484" class="size-full wp-image-4484" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png" alt="Include JSON driver in ODBC Data source" width="590" height="423" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator.png 590w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-new-data-source-odbc-administrator-300x215.png 300w" sizes="(max-width: 590px) 100vw, 590px" /></a><p id="caption-attachment-4484" class="wp-caption-text">Add new ODBC driver</p></div></li>
<li>Secondly, select the ZappySys JSON Driver:
<div id="attachment_4485" style="width: 471px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4485" class="size-full wp-image-4485" src="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png" alt="Use ZappySys ODBC Driver" width="461" height="346" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1.png 461w, https://zappysys.com/blog/wp-content/uploads/2018/07/create-new-data-source-zappysys-json-driver-1-300x225.png 300w" sizes="(max-width: 461px) 100vw, 461px" /></a><p id="caption-attachment-4485" class="wp-caption-text">Select JSON driver in ODBC DS Administrator</p></div></li>
<li>Also, add this URL to the ZappySys JSON Driver:<br />
<pre class="crayon-plain-tag">https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json</pre>
<div id="attachment_4488" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4488" class="size-full wp-image-4488" src="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png" alt="URL for OData REST API" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-json-driver-url-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4488" class="wp-caption-text">REST API ODBC URL</p></div></li>
</ol>
<h3>ZappySys Gateway to connect Java to REST API</h3>
<p>In order to connect Java to REST API, we will use a Gateway that is installed with the ZappySys ODBC PowerPack. This gateway uses a SQL Server connection. Let&#8217;s take a look at the steps.</p>
<ol>
<li>First of all, open the ZappysSys Data Gateway Configuration.</li>
<li>Secondly, press the add button and create a new data source named customer:
<div id="attachment_4490" style="width: 567px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4490" class="size-full wp-image-4490" src="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png" alt="Gateway add Data Source" width="557" height="209" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway.png 557w, https://zappysys.com/blog/wp-content/uploads/2018/07/zappysys-data-gateway-300x113.png 300w" sizes="(max-width: 557px) 100vw, 557px" /></a><p id="caption-attachment-4490" class="wp-caption-text">Add new Data Source in ZappySys Gateway</p></div></li>
<li>Also, enable the custom data source and make sure to check the public option.</li>
<li>In addition, press the Edit and add the ODBC Data Source created in the Add ZappySys ODBC Driver to connect to REST API section:<br />
<pre class="crayon-plain-tag">&lt;strong&gt;NOTE:&lt;/strong&gt; Whenever possible use native driver option for better performance / security and ease of use.</pre>
<div style="width: 568px" class="wp-caption alignnone"><img loading="lazy" decoding="async" class="size-full" src="https://i0.wp.com/zappysys.com/blog/wp-content/uploads/2018/11/zappysys-data-gateway-add-data-source.png?w=720&amp;ssl=1" alt="Native ODBC Driver" width="558" height="533" /><p class="wp-caption-text">Zappysys ODBC driver</p></div></li>
<li>Additionally, we will add a new user:
<div id="attachment_4492" style="width: 690px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4492" class="size-full wp-image-4492" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source.png" alt="Create a new user and add permission" width="680" height="616" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source.png 680w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-300x272.png 300w" sizes="(max-width: 680px) 100vw, 680px" /></a><p id="caption-attachment-4492" class="wp-caption-text">Add the user to the data source gateway</p></div></li>
<li>Also, add the user to the data source:
<div id="attachment_4493" style="width: 690px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4493" class="size-full wp-image-4493" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1.png" alt="Data source with a new user" width="680" height="616" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1.png 680w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-user-to-data-source-1-300x272.png 300w" sizes="(max-width: 680px) 100vw, 680px" /></a><p id="caption-attachment-4493" class="wp-caption-text">Add user to the data source</p></div></li>
<li>Finally, check the default port in the general tab. By default this value is 5000:
<div id="attachment_4495" style="width: 572px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4495" class="size-full wp-image-4495" src="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png" alt="Port 5000 in the default gateway" width="562" height="539" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port.png 562w, https://zappysys.com/blog/wp-content/uploads/2018/07/gateway-zappysys-default-port-300x288.png 300w" sizes="(max-width: 562px) 100vw, 562px" /></a><p id="caption-attachment-4495" class="wp-caption-text">Default gateway with port 5000</p></div></li>
</ol>
<p>&nbsp;</p>
<h3>Connect Java to REST API</h3>
<ol>
<li>First of all, we will first try to connect to the following URL:<br />
<pre class="crayon-plain-tag">https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json</pre>
</li>
<li>Secondly, we will get the countries and the sum or quantity orders using the following code:<br />
<pre class="crayon-plain-tag">package padaone;

import java.sql.*;

public class zappy {

	public static void main(String[] args) {
		
		// Create a variable for the connection string.
		String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=customer;user=test;password=test";

		// Declare the JDBC objects.
		Connection con = null;
		Statement stmt = null;
		ResultSet rs = null;
		
        	try {
        		// Establish the connection.
        		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            		con = DriverManager.getConnection(connectionUrl);
            
            		// Create and execute an SQL statement that returns some data.
            		String SQL = "SELECT Country , SUM(UnitPrice * Quantity) Total " 
	+ "FROM value " 
	+ "GROUP BY Country " 
	+ "WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json')";
            		stmt = con.createStatement();
            		rs = stmt.executeQuery(SQL);
            
            		// Iterate through the data in the result set and display it.
            		while (rs.next()) {
            			System.out.println(rs.getString(1) + " " + rs.getString(2));
            		}
        	}
        
		// Handle any errors that may have occurred.
		catch (Exception e) {
			e.printStackTrace();
		}

		finally {
			if (rs != null) try { rs.close(); } catch(Exception e) {}
	    		if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	    		if (con != null) try { con.close(); } catch(Exception e) {}
		}
	}
}</pre>
</li>
<li>In addition, in the project, go to libraries, right click and select the option to add JAR or folder and select the sqljdbc42.jar. This jar file is used to connect to SQL Server. The ZappySys ODBC PowerPack uses the SQL Server JDBC connector with a gateway to connect to REST API or JSON files:
<div id="attachment_4499" style="width: 324px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4499" class="size-full wp-image-4499" src="https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file.png" alt="Add library in NetBeans" width="314" height="449" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file.png 314w, https://zappysys.com/blog/wp-content/uploads/2018/07/java-netbeans-add-jar-file-210x300.png 210w" sizes="(max-width: 314px) 100vw, 314px" /></a><p id="caption-attachment-4499" class="wp-caption-text">Add SQL Server jar file</p></div></li>
<li>Also, we will need to add the sqljdb4.2.jar and the sqljdbc_auth.dll in the <strong>C:/Windows/System32</strong> and the path where the JDK is installed (in this example <strong>C:/Program Files/Java/jdk1.8.0_171/bin)</strong>.</li>
<li>Finally, run the code and you will visualize the query results of the REST API:
<div id="attachment_4501" style="width: 383px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4501" class="size-full wp-image-4501" src="https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results.png" alt="Show REST API results in Java" width="373" height="264" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results.png 373w, https://zappysys.com/blog/wp-content/uploads/2018/07/java-rest-api-results-300x212.png 300w" sizes="(max-width: 373px) 100vw, 373px" /></a><p id="caption-attachment-4501" class="wp-caption-text">REST API results in Java</p></div></li>
</ol>
<h3>Explanation of the code to Connect Java to REST API</h3>
<p>Previously, we run the code to query REST API data in Java. Now we will explain the code.</p>
<ol>
<li>First of all, we will import the java.sql to connect to SQL Server using Java:<br />
<pre class="crayon-plain-tag">import java.sql.*;</pre>
</li>
<li>Secondly, we will create a connection to the ZappySys Gateway. Using the port 5000 and we are using the data source and user created in the Add ZappySys ODBC Driver to connect to REST API:<br />
<pre class="crayon-plain-tag">String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=customer;
user=test;password=test";</pre>
</li>
<li>Also, we will set the variables to null to initialize them:<br />
<pre class="crayon-plain-tag">Connection con = null;
Statement stmt = null;
ResultSet rs = null;</pre>
</li>
<li>In addition, we will connect to the JDBC SQL driver:<br />
<pre class="crayon-plain-tag">Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);</pre>
</li>
<li>Additionally, we will send a query to the URL and get the country and the sum of price multiplied by quantity, group by country:<br />
<pre class="crayon-plain-tag">String SQL = "SELECT Country , SUM(UnitPrice * Quantity) Total " 
	+ "FROM value " 
	+ "GROUP BY Country " 
	+ "WITH (SRC='https://services.odata.org/V3/Northwind/Northwind.svc/Invoices?$format=json')";
            		stmt = con.createStatement();
            		rs = stmt.executeQuery(SQL);</pre>
</li>
<li>Next, we will print the results of the query:<br />
<pre class="crayon-plain-tag">while (rs.next()) {
   System.out.println(rs.getString(1) + " " + rs.getString(2));
}</pre>
</li>
<li>Finally, we will close all the connections:<br />
<pre class="crayon-plain-tag">finally {
			if (rs != null) try { rs.close(); } catch(Exception e) {}
	    		if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	    		if (con != null) try { con.close(); } catch(Exception e) {}
		}</pre>
&nbsp;</li>
</ol>
<h3>How to connect to multiple JSON files</h3>
<p>The ZappySys ODBC PowerPack can be used to easily read local JSON files in Java and query using SQL with SELECT, WHERE, GROUP BY, HAVING and other SQL clauses. For more information, refer to this <a href="https://zappysys.com/onlinehelp/odbc-powerpack/index.htm#page=json-odbc-driver-sql-query-examples.htm" target="_blank" rel="noopener">link</a>.</p>
<ol>
<li>The following code will list the files and the content of the JSON files:<br />
<pre class="crayon-plain-tag">package padaone;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class localfile {
    public static void main(String[] args) {
        File directory = new File ("C:\\temp");
        File[] list = directory.listFiles();
        
        printNames(list);	
    }

    private static void printNames(File[] list) {
        for(int i =0;i&lt;list.length;i++){
            if(list[i].isFile()){
                System.out.println(list[i].getName());

                
                showContent(list[i]);
                
            }
        }
    }

    private static void showContent(File file) {
      
        // Create a variable for the connection string.
        String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=customer;user=test;password=test";

        // Declare the JDBC objects.
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;

        try {
                // Establish the connection.
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                con = DriverManager.getConnection(connectionUrl);

                // Create and execute an SQL statement that returns some data.
                String SQL = "SELECT * FROM $ WITH (SRC='C:\\temp\\"+file.getName()+"')";
                stmt = con.createStatement();
                rs = stmt.executeQuery(SQL);

                // Iterate through the data in the result set and display it.
                while (rs.next()) {
                        System.out.println(rs.getString(1) + " " + rs.getString(2));//+ " " + rs.getString(3)+ " " + rs.getString(4)+ " " + rs.getString(5)+ " " + rs.getString(6));
                }
        }

        // Handle any errors that may have occurred.
        catch (Exception e) {
                e.printStackTrace();
        }

        finally {
                if (rs != null) try { rs.close(); } catch(Exception e) {}
                if (stmt != null) try { stmt.close(); } catch(Exception e) {}
                if (con != null) try { con.close(); } catch(Exception e) {}
        }
	
    }

}</pre>
</li>
<li>The JSON files are the following:<br />
<pre class="crayon-plain-tag">example_1.json

[{
  "id": 1,
  "first_name": "Jeanette",
  "last_name": "Penddreth",
  "email": "jpenddreth0@census.gov",
  "gender": "Female",
  "ip_address": "26.58.193.2"
}, {
  "id": 2,
  "first_name": "Giavani",
  "last_name": "Frediani",
  "email": "gfrediani1@senate.gov",
  "gender": "Male",
  "ip_address": "229.179.4.212"
}, {
  "id": 3,
  "first_name": "Noell",
  "last_name": "Bea",
  "email": "nbea2@imageshack.us",
  "gender": "Female",
  "ip_address": "180.66.162.255"
}, {
  "id": 4,
  "first_name": "Willard",
  "last_name": "Valek",
  "email": "wvalek3@vk.com",
  "gender": "Male",
  "ip_address": "67.76.188.26"
}]

example_2.json

{
    "quiz": {
        "sport": {
            "q1": {
                "question": "Which one is correct team name in NBA?",
                "options": [
                    "New York Bulls",
                    "Los Angeles Kings",
                    "Golden State Warriros",
                    "Huston Rocket"
                ],
                "answer": "Huston Rocket"
            }
        },
        "maths": {
            "q1": {
                "question": "5 + 7 = ?",
                "options": [
                    "10",
                    "11",
                    "12",
                    "13"
                ],
                "answer": "12"
            },
            "q2": {
                "question": "12 - 8 = ?",
                "options": [
                    "1",
                    "2",
                    "3",
                    "4"
                ],
                "answer": "4"
            }
        }
    }
}</pre>
</li>
<li>Finally, if everything is fine, you will be able to see the file names<br />
and the content:</p>
<div id="attachment_4505" style="width: 886px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4505" class="size-full wp-image-4505" src="https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java.png" alt="JSON files read in Java" width="876" height="246" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java.png 876w, https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java-300x84.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/json-files-read-java-768x216.png 768w" sizes="(max-width: 876px) 100vw, 876px" /></a><p id="caption-attachment-4505" class="wp-caption-text">Read JSON files in Java</p></div></li>
</ol>
<h3>How to connect Java to REST API Gmail</h3>
<p>Connect Java to Google, Facebook, OneDrive or other REST API tools is a straightforward process using the ZappySys ODBC Driver. You just need to create the Data Source in ODBC and then create a ZappySys Gateway, the rest is simple in Java. Let&#8217;s take a look at an example.</p>
<ol>
<li>First of all, we will create a new Data source in the Windows ODBC Data<br />
Source Administrator. We will create a new ZappySys JSON Driver and add the following link:<br />
<pre class="crayon-plain-tag">https://www.googleapis.com/gmail/v1/users/me/messages/</pre>
</li>
<li>Secondly, select the OAuth connection type and $.messages[*] in the<br />
filter and press the Click to Configure link:</p>
<div id="attachment_4507" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4507" class="size-full wp-image-4507" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API.png" alt="Create ODBC connection to Gmail" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ODBC-Driver-to-gmail-REST-API-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4507" class="wp-caption-text">Setup ODBC configuration to URL</p></div></li>
<li>Also, in the OAuth parameters link, select the Google OAuth Provider.</li>
<li>In addition in scopes write the scope https://mail.google.com:
<div id="attachment_4508" style="width: 596px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4508" class="size-full wp-image-4508" src="https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API.png" alt="Use Java to connect to Gmail" width="586" height="493" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API.png 586w, https://zappysys.com/blog/wp-content/uploads/2018/07/OAuth-configuration-Gmail-REST-API-300x252.png 300w" sizes="(max-width: 586px) 100vw, 586px" /></a><p id="caption-attachment-4508" class="wp-caption-text">Rest API connect to Gmail</p></div></li>
<li>Additionally, in the preview tab, you can generate your queries and save<br />
your Data Source:</p>
<div id="attachment_4510" style="width: 812px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4510" class="size-full wp-image-4510" src="https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information.png" alt="Create REST API gmail queries" width="802" height="702" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information.png 802w, https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information-300x263.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/generate-queries-to-gmail-information-768x672.png 768w" sizes="(max-width: 802px) 100vw, 802px" /></a><p id="caption-attachment-4510" class="wp-caption-text">Connect Java to REST API</p></div></li>
<li>Next, open your ZappySys Data Gateway. We will create a new Data Source<br />
named gm:</p>
<div id="attachment_4511" style="width: 570px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4511" class="wp-image-4511 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source.png" alt="Use gateway to connect Java to REST API" width="560" height="280" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source.png 560w, https://zappysys.com/blog/wp-content/uploads/2018/07/gm-new-data-source-300x150.png 300w" sizes="(max-width: 560px) 100vw, 560px" /></a><p id="caption-attachment-4511" class="wp-caption-text">Add Gmail Data Source</p></div></li>
<li>Also, we will associate the ODBC Data Source with the Gateway Data Source. Make sure to add the test user to the Gateway data source:
<div id="attachment_4513" style="width: 573px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4513" class="size-full wp-image-4513" src="https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source.png" alt="Add ODBC data source to gateway" width="563" height="539" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source.png 563w, https://zappysys.com/blog/wp-content/uploads/2018/07/add-gmail-rest-api-data-source-300x287.png 300w" sizes="(max-width: 563px) 100vw, 563px" /></a><p id="caption-attachment-4513" class="wp-caption-text">Include the data source for the ODBC</p></div></li>
<li>Finally, you can run this code. The code in Java will connect to the Gateway data source using the port 5000 and the Gateway user and password. The query will show the Gmail message ids:<br />
<pre class="crayon-plain-tag">package padaone;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class gmail {
    public static void main(String[] args) {
		
		// Create a variable for the connection string.
		String connectionUrl = "jdbc:sqlserver://localhost:5000;databasename=gm;user=test;password=test";

		// Declare the JDBC objects.
		Connection con = null;
		Statement stmt = null;
		ResultSet rs = null;
		
        	try {
        		// Establish the connection.
        		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            		con = DriverManager.getConnection(connectionUrl);
            
            		// Create and execute an SQL statement that returns some data.
            		String SQL = "SELECT id FROM [_root_]";
            		stmt = con.createStatement();
            		rs = stmt.executeQuery(SQL);
            
            		// Iterate through the data in the result set and display it.
            		while (rs.next()) {
            			System.out.println(rs.getString(1));
            		}
        	}
        
		// Handle any errors that may have occurred.
		catch (Exception e) {
			e.printStackTrace();
		}

		finally {
			if (rs != null) try { rs.close(); } catch(Exception e) {}
	    		if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	    		if (con != null) try { con.close(); } catch(Exception e) {}
		}
	}
}</pre>
</li>
<li>You can find your message id in Google by clicking your messages:
<div id="attachment_4514" style="width: 392px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4514" class="size-full wp-image-4514" src="https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id.png" alt="Using Java to get Gmail info" width="382" height="238" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id.png 382w, https://zappysys.com/blog/wp-content/uploads/2018/07/Java-results-email-id-300x187.png 300w" sizes="(max-width: 382px) 100vw, 382px" /></a><p id="caption-attachment-4514" class="wp-caption-text">Display Gmail information in Java</p></div></li>
</ol>
<h2>ZappySys JSON /REST API Driver Query Examples</h2>
<p>Reading from XML files or API can be done using the same way as previous sections except you have to use ZappySys XML Driver. Read help file here to <a href="https://zappysys.com/onlinehelp/odbc-powerpack/scr/json-odbc-driver-sql-query-examples.htm" target="_blank" rel="noopener">see json query examples</a>.</p>
<h2>ZappySys XML / SOAP Driver Query Examples</h2>
<p>Reading from XML files or API can be done using the same way as previous sections except you have to use ZappySys XML Driver. Read help file here to <a href="https://zappysys.com/onlinehelp/odbc-powerpack/scr/xml-odbc-driver-sql-query-examples.htm" target="_blank" rel="noopener">see xml query examples</a>.</p>
<h2>Calling XML SOAP Web Service in JAVA</h2>
<p>So far we have looked at examples to consume data using JSON driver. Now lets look at an example, to call XML SOAP Web Service in JAVA.</p>
<div class="content_block" id="custom_post_widget-3870">To call SOAP API you need to know Request XML Body Structure. If you are not sure how to create SOAP Request body then no worries. <a href="https://zappysys.com/blog/calling-soap-web-service-in-ssis-xml-source/" target="_blank" rel="noopener">Check this article</a> to learn how to generate SOAP Request body using the Free tool <a href="https://www.soapui.org/downloads/latest-release.html" target="_blank" rel="noopener">SoapUI</a>. Basically, you have to use SoapUI to generate Request XML and after that, you can replace parameters as needed in the generated body.
<h3>What is SOAP Web Service?</h3>
If you are new to SOAP Web Service sometimes referred as XML Web Service then please read some concept about SOAP Web service standard <a href="https://msdn.microsoft.com/en-us/library/ms996507.aspx?f=255&amp;MSPPError=-2147217396" target="_blank" rel="noopener">from this link</a>

There are two important aspects in SOAP Web service.
<ol>
 	<li>Getting WSDL file or URL</li>
 	<li>Knowing exact Web Service URL</li>
</ol>
<h3>What is WSDL</h3>
In very simple term WSDL (often pronounced as whiz-dull) is nothing but a document which describes Service metadata (e.g. Functions you can call, Request parameters, response structure etc). Some service simply give you WSDL as xml file you can download on local machine and then analyze or sometimes you may get direct URL (e.g. http://api.mycompany.com/hr-soap-service/?wsdl )
<h3>Example SQL Query for SOAP API call using ZappySys XML Driver</h3>
Here is an example SQL query you can write to call SOAP API. If you not sure about many details then check next few sections on how to use XML Driver User Interface to build desired SQL query to POST data to XML SOAP Web Service without any coding.
<pre class="lang:tsql decode:true">SELECT * FROM $
WITH(
	 Src='http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx'
	,DataConnectionType='HTTP'
	,CredentialType='Basic' --OR SoapWss
	,SoapWssPasswordType='PasswordText'
	,UserName='myuser'
	,Password='pass$$w123'
	,Filter='$.soap:Envelope.soap:Body.GetHolidaysAvailableResponse.GetHolidaysAvailableResult.HolidayCode[*]'
	,ElementsToTreatAsArray='HolidayCode'	
	,RequestMethod='POST'	
	,Header='Content-Type: text/xml;charset=UTF-8 || SOAPAction: "http://www.holidaywebservice.com/HolidayService_v2/GetHolidaysAvailable"'
	,RequestData='
&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hol="http://www.holidaywebservice.com/HolidayService_v2/"&gt;
   &lt;soapenv:Header/&gt;
   &lt;soapenv:Body&gt;
      &lt;hol:GetHolidaysAvailable&gt;
         &lt;!--type: Country - enumeration: [Canada,GreatBritain,IrelandNorthern,IrelandRepublicOf,Scotland,UnitedStates]--&gt;
         &lt;hol:countryCode&gt;UnitedStates&lt;/hol:countryCode&gt;
      &lt;/hol:GetHolidaysAvailable&gt;
   &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;'
)</pre>
Now let's look at steps to create SQL query to call SOAP API. Later we will see how to generate code for your desired programming language (e.g. C# or SQL Server)
<h3>Video Tutorial - Introduction to SOAP Web Service and SoapUI tool</h3>
Before we dive into details about calling SOAP API using ZappySys XML Driver, lets first understand what is SOAP API and how to create SOAP requests using SoapUI tool. You will learn more about this process in the later section. The video contains some fragment about using SOAP API in SSIS but just ignore that part because we will be calling Soap API using ZappySys ODBC Driver rather than SSIS Components.

&nbsp;

<iframe loading="lazy" width="560" height="315" src="https://www.youtube.com/embed/d_x5bgGjg0Y?rel=0&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen="allowfullscreen" data-mce-fragment="1"></iframe>
<h3>Using SoapUI to test SOAP API call / Create Request Body XML</h3>
Assuming you have downloaded and installed <a href="https://www.soapui.org/downloads/latest-release.html" target="_blank" rel="noopener">SoapUI from here</a>, now we are ready to use WSDL for your SOAP Web Service Calls. If you do not have WSDL file or URL handy then contact your API provider (sometimes you just have to add <strong>?wsdl </strong>at the end of your Service URL to get WSDL so try that. Example: http://mycompany/myservice?wsdl ).

If you don't know what is WSDL then in short, WSDL is <strong>Web service Description Language</strong> (i.e. XML file which describes your SOAP Service). WSDL helps to craft SOAP API request Body for ZappySys XML Driver. So Let's get started.
<ol>
 	<li>Open SoapUI and click SOAP button to create new SOAP Project</li>
 	<li>Enter WSDL URL or File Path of WSDLFor example WSDL for our sample service can be accessed via this URL
<pre class="lang:default highlight:0 decode:true">http://www.dneonline.com/calculator.asmx?wsdl</pre>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-api-import-wsdl-new-soapui-project.png"><img loading="lazy" decoding="async" class="size-full wp-image-3871" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-14.png" alt="Create new SOAP API Project in SoapUI tool for SOAP API Testing" width="486" height="349" /></a>
<div style="margin-bottom: 1em;">Create new SOAP API Project in SoapUI tool for SOAP API Testing</div></li>
 	<li>Once WSDL is loaded you will see possible operations you can call for your SOAP Web Service.</li>
 	<li>If your web service requires credentials then you have to configure it. There are two common credential types for public services (<strong>SOAP WSS</strong> or <strong>BASIC</strong> )
<ol>
 	<li>
<div style="margin-bottom: 1em;">To use <strong>SOAP WSS Credentials</strong> select request node and enter UserId, Password, and <strong>WSS-PasswordType</strong> (PasswordText or PasswordHash)</div>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-api-pass-soap-wss-credentials-userid-password.png"><img loading="lazy" decoding="async" class="size-full wp-image-3872 alignnone" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-2.png" alt="Configure SOAP WSS Credentials for SoapUI (SOAP API Testing Tool)" width="294" height="544" /></a>
<div style="display: block;">Configure SOAP WSS Credentials for SoapUI (SOAP API Testing Tool)</div></li>
 	<li>To use <strong>BASIC Auth</strong> Credentials select request node and double-click it. At the bottom click on Auth (Basic) and From Authorization dropdown click Add New and Select Basic.<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-api-pass-basic-authentication-userid-password.png"><img loading="lazy" decoding="async" class="size-full wp-image-3873" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-2.png" alt="Configure Basic Authorization for SoapUI (SOAP API Testing Tool)" width="616" height="653" /></a>
<div style="margin-bottom: 1em;">Configure Basic Authorization for SoapUI (SOAP API Testing Tool)</div></li>
</ol>
</li>
 	<li>Now you can test your request first Double-click on the request node to open request editor.</li>
 	<li>Change necessary parameters, remove optional or unwanted parameters. If you want to regenerate request you can click on <strong>Recreate default request toolbar icon</strong>.
<a href="https://zappysys.com/blog/wp-content/uploads/2016/06/create-soap-request-with-optional-parameters-soapui.png"><img loading="lazy" decoding="async" class="size-full wp-image-2812" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-4.png" alt="Create SOAP Request XML (With Optional Parameters)" width="807" height="315" /></a>
<div style="margin-bottom: 1em;">Create SOAP Request XML (With Optional Parameters)</div></li>
 	<li>Once your SOAP Request XML is ready, <strong>Click the Play button</strong> in the toolbar to execute SOAP API Request and Response will appear in Right side panel.
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/soapui-test-soap-api-request-response-edit-xml-body.png"><img loading="lazy" decoding="async" class="size-full wp-image-3874" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-5.png" alt="Test SOAP API using SoapUI Tool (Change Default XML Body / Parameters, Execute and See Response)" width="1216" height="511" /></a>
Test SOAP API using SoapUI Tool (Change Default XML Body / Parameters, Execute and See Response)</li>
</ol>
<h3>Create DSN using ZappySys XML Driver to call SOAP API</h3>
Once you have tested your SOAP API in SoapUI tool, we are ready to use ZappySys XML driver to call SOAP API in your preferred BI tool or Programming language.
<ol>
 	<li>First open <strong>ODBC Data Sources</strong> (search ODBC in your start menu or go under ZappySys &gt; ODBC PowerPack &gt; <strong>ODBC 64 bit</strong>)</li>
 	<li>Goto <strong>System DSN</strong> Tab (or User DSN which is not used by Service account)</li>
 	<li>Click <strong>Add</strong> and Select ZappySys XML Driver
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/zappysys-odbc-xml-soap-api-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3875" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-6.png" alt="ZappySys ODBC Driver for XML / SOAP API" width="593" height="459" /></a>
ZappySys ODBC Driver for XML / SOAP API</li>
 	<li>Configure API URL, Request Method and Request Body as below
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-web-service-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3876" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-7.png" alt="ZappySys XML Driver - Calling SOAP API - Configure URL, Method, Body" width="916" height="874" /></a>
ZappySys XML Driver - Calling SOAP API - Configure URL, Method, Body</li>
 	<li><strong>(This step is Optional)</strong> If your SOAP API requires credentials then Select Connection Type to HTTP and configure as below.
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/soap-api-call-credential-basic-soap-wss-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3877" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-8.png" alt="ZappySys XML Driver - Configure SOAP WSS Credentials or Basic Authorization (Userid, Password)" width="564" height="483" /></a>
<div style="display: block;">ZappySys XML Driver - Configure SOAP WSS Credentials or Basic Authorization (Userid, Password)</div></li>
 	<li>Configure-Request Headers as below (You can get it from Request &gt; Raw tab from SoapUI after you test the request by clicking the Play button)
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/set-soap-api-request-headers-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3881" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-9.png" alt="Configure SOAP API Request Headers - ZappySys XML Driver" width="1009" height="747" /></a>
Configure SOAP API Request Headers - ZappySys XML Driver</li>
 	<li>Once credentials entered you can select Filter to extract data from the desired node. Make sure to select array node (see special icon) or select the node which contains all necessary columns if you don't have array node.
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/soap-api-query-select-filter-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3882" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-10.png" alt="Select Filter - Extract data from nested XML / SOAP API Response (Denormalize Hierarchy)" width="809" height="594" /></a>
Select Filter - Extract data from nested XML / SOAP API Response (Denormalize Hierarchy)</li>
 	<li>If prompted select yes to treat selected node as Array (This is helpful when you expect one or more record for selected node)
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/xml-api-array-handling-zappysys-xml-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3883" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-11.png" alt="Treat selected node as XML Array Option for SOAP API Response XML" width="655" height="572" /></a>
Treat selected node as XML Array Option for SOAP API Response XML</li>
</ol>
<h3>Preview SOAP API Response / Generate SQL Code for SOAP API Call</h3>
Once you configure settings for XML Driver now you can preview data or generate example code for desired language (e.g. C#, Python, Java, SQL Server).

Go to Preview tab and you will see default query generated based on settings you entered in previous sections. Attributes listed in WITH clause are optional. If you omit attribute in WITH clause it will use it from Properties tab.
<h3>Preview Data</h3>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/calling-soap-web-service-zappysys-xml-api-driver.png"><img loading="lazy" decoding="async" class="size-full wp-image-3884" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-12.png" alt="Preview SOAP API Response in ZappySys XML Driver" width="808" height="780" /></a>
Preview SOAP API Response in ZappySys XML Driver
<h3>Generate Code Option</h3>
<a href="https://zappysys.com/blog/wp-content/uploads/2018/06/zappysys-driver-code-generator.png"><img loading="lazy" decoding="async" class="size-full wp-image-3885" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-call-soap-api-13.png" alt="Generate Example Code for ZappySys Driver" width="572" height="618" /></a>
<div style="display: block;">Generate Example Code for ZappySys Driver</div></div>
<h2>POST data to REST API URL from file in JAVA</h2>
<p>Above example was POST data to API URL but what if your Request Body is large and you have saved that to file? Well here is the way to get your request body from a file (Use @ symbol before path).</p><pre class="crayon-plain-tag">SELECT * FROM $
WITH 
(METHOD='POST' 
,HEADER='Content-Type:text/plain || x-hdr1:AAA'
,SRC='http://httpbin.org/post'
,BODY='@c:\files\dump.xml'
,IsMultiPart='True'
)</pre><p>
&nbsp;</p>
<h2>REST API Pagination in JAVA</h2>
<div class="content_block" id="custom_post_widget-3892"><div style="margin-bottom: 1em;">Even we set up ODBC Data Source to get the data, it may not be enough. Usually, if you are getting a huge data set from API provider, it won't give it to you in one HTTP response. Instead, it gives back only a subset of data and provides a mechanism for data pagination. The good news is that <em>ZappySys ODBC Driver</em> includes many options to cover virtually any pagination method.</div>
<div><span style="font-size: 16px;">Below you will find a few examples of API pagination. If you need something more sophisticated check the below link (the article was written for SSIS PowerPack but UI options and concepts apply to ODBC Driver too):</span></div>
<div style="margin-bottom: 1em;"><a href="https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/" target="_blank" rel="noopener">https://zappysys.com/blog/ssis-rest-api-looping-until-no-more-pages-found/</a></div>
<h3>Paginate by Response Attribute</h3>
This example shows how to paginate API calls where you need to paginate until the last page detected. In this example, next page is indicated by some attribute called nextlink (found in response). If this attribute is missing or null then it stops fetching the next page.
<pre class="lang:tsql decode:true codeblock">SELECT * FROM $
WITH(
SRC=@'https://zappysys.com/downloads/files/test/pagination_nextlink_inarray_1.json'
,NextUrlAttributeOrExpr = '$.nextlink'  --keep reading until this attribute is missing. If attribute name contains dot then use brackets like this $.['my.attr.name']
)</pre>
<h3>Paginate by URL Parameter (Loop until certain StatusCode)</h3>
This example shows how to paginate API calls where you need to pass page number via URL. The driver keeps incrementing page number and calls next URL until the last page detected (401 error). There are few ways to indicate the last page (e.g. By status code, By row count, By response size). If you don't specify end detection then it will use the default (i.e. No records found).
<pre class="lang:tsql decode:true codeblock">SELECT * FROM $
WITH (
SRC=@'https://zappysys.com/downloads/files/test/page-xml.aspx?page=1&amp;mode=DetectBasedOnResponseStatusCode'
,PagingMode='ByUrlParameter'
,PagingByUrlAttributeName='page'
,PagingByUrlEndStrategy='DetectBasedOnResponseStatusCode'
,PagingByUrlCheckResponseStatusCode=401
,IncrementBy=1
)</pre>
<h3>Paginate by URL Path (Loop until no record)</h3>
This example shows how to paginate API calls where you need to pass page number via URL Path. The driver keeps incrementing page number and calls next URL until the last page is detected. There are few ways to indicate the last page (e.g. By status code, By row count, By response size). If you don't specify end detection then it will use the default (i.e. No records found).
<pre class="lang:tsql decode:true codeblock">SELECT * FROM $
WITH (
SRC=@'https://zappysys.com/downloads/files/test/cust-&lt;%page%&gt;.xml'
,PagingMode='ByUrlPath'
,PagingByUrlAttributeName='&lt;%page%&gt;'
,PagingByUrlEndStrategy='DetectBasedOnRecordCount'
,IncrementBy=1
)</pre>
<h3>Paginate by Header Link (RFC 5988)</h3>
API like GitHub / Wordpress use Next link in Headers (<a href="https://tools.ietf.org/html/rfc5988" target="_blank" rel="noopener">RFC 5988</a>)
<pre class="lang:default decode:true ">SELECT * FROM $
LIMIT 25
WITH(
	 Src='https://wordpress.org/news/wp-json/wp/v2/categories?per_page=10'
	,PagingMode='ByResponseHeaderRfc5988'
	,WaitTimeMs='200' --//wait 200 ms after each request
)</pre>
&nbsp;</div>
<h2>Error Handling in REST API / SOAP</h2>
<div class="content_block" id="custom_post_widget-3894">Sometimes errors occur... they just do and there is nothing you can do! Or can you? Actually, in ODBC PowerPack you can handle them in two ways.
<h3>METHOD 1 - Using Error Handling Options</h3>
<img loading="lazy" decoding="async" class="alignnone size-full wp-image-3949" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-error-handling-1.png" alt="" width="668" height="702" />
<h4>When to use?</h4>
You may want to use them when your source is a resource located on the Internet; e.g. a file on a website, a file on an FTP server or just a plain API HTTP response. By default, when a remote server returns an error, data retrieval is stopped, an error is raised and no data is given back to you. This might not be always desirable.
<h4>Scenario 1</h4>
Imagine a scenario, that there is a web server which each day at 12 AM releases a new JSON file with that day's date as filename, e.g. <span style="text-decoration: underline;"><em>http://www.some-server.com/data/2018-06-20.json</em></span>. And, of course, you want to download it and use it daily in your Power BI report. But you have a problem: Power BI report data sources are refreshed each hour and you may get <a href="https://en.wikipedia.org/wiki/HTTP_404" target="_blank" rel="noopener">HTTP 404 status code</a> (no file was found) when a file is not released yet. Which consequentially means other data sources won't be updated as well and you will see old and cached data on the report. That's where you could use <strong><span class="lang:default highlight:0 decode:true crayon-inline">Continue on any error</span></strong> or <strong><span class="lang:default highlight:0 decode:true crayon-inline">Continue when Url is invalid or missing (404 Errors)</span></strong> to avoid an error being raised and let other data sources to be updated.
<h4>Scenario 2</h4>
Another scenario is when you expect a web server to raise some kind of HTTP error when accessing a URL. You don't want ODBC Data Source to raise an error but instead, you want to get response data. That's where you can use <strong><span class="lang:default highlight:0 decode:true crayon-inline">Continue on any error</span></strong> or alike together with  <strong><span class="lang:default highlight:0 decode:true crayon-inline">Get response data on error</span></strong> to continue on an error and get the data:

<img loading="lazy" decoding="async" class="alignnone wp-image-3961 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-get-response-data-on-error.png" alt="" width="547" height="235" srcset="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-get-response-data-on-error.png 547w, https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-get-response-data-on-error-300x129.png 300w" sizes="(max-width: 547px) 100vw, 547px" />
<h3>METHOD 2 - Using Connection [Retry Settings]</h3>
Another scenario you may run into is a buggy web server. You ask it to give you some file or data and it, like a snotty kid, just doesn't give it to you! You have to ask twice or thrice before it does its job. If that's the case, you have to retry HTTP requests using <em>Connection</em>:

<img loading="lazy" decoding="async" class="alignnone wp-image-3963 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-error-handling-3.png" alt="" width="671" height="572" /></div>
<h2>REST API / SOAP Connection Types in JAVA (OAuth / HTTP)</h2>
<div class="content_block" id="custom_post_widget-3896"><div style="margin-bottom: 1em;">If you need to authenticate or authorize your user to access a web resource, you will need to use one of the <em>Connections:</em></div>
<ul>
 	<li>HTTP</li>
 	<li>OAuth</li>
</ul>
<img loading="lazy" decoding="async" class="wp-image-4078 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-authentication-authorization-e1529337108252.png" alt="ZappySys XML Driver - HTTP and OAuth Connection Types" width="577" height="302" srcset="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-authentication-authorization-e1529337108252.png 577w, https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-powerpack-authentication-authorization-e1529337108252-300x157.png 300w" sizes="(max-width: 577px) 100vw, 577px" />
<h3>HTTP Connection</h3>
<div style="margin-bottom: 1em;">Use <em>HTTP Connection</em> for simple Windows, Basic, NTLM or Kerberos authentication. Just fill in a username and a password and you are good to go!</div>
<div style="margin-bottom: 1em;">You can also use <em>HTTP Connection</em> for more sophisticated authentication like:</div>
<ul>
 	<li><strong>SOAP WSS</strong> (when accessing a SOAP WebService)</li>
 	<li><strong>Static Token / API Key</strong> (when need to pass an API key in HTTP header)</li>
 	<li><strong>Dynamic Token</strong> (same as Static Token method except that each time you need to log in and retrieve a fresh API key)</li>
 	<li><strong>JWT Token</strong> (As per RFC 7519)</li>
</ul>
<img loading="lazy" decoding="async" class="alignnone wp-image-4091 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-connection-type-1.png" alt="" width="622" height="570" />
<h3>OAuth</h3>
If you are trying to access REST API resource, it is a huge chance, you will need to use <em>OAuth Connection</em>. <a href="https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/" target="_blank" rel="noopener">Read this article</a> to understand how OAuth authentication and authorization works and how to use it (article originally was written for <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a>, but the concepts and UI stay the same): <br/>
<a href="https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/" target="_blank" rel="noopener">https://zappysys.com/blog/rest-api-authentication-with-oauth-2-0-using-ssis/</a>
<img loading="lazy" decoding="async" class="alignnone size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/06/odbc-api-connection-type-2.png" width="721" height="708" /></div>
<h2>Performance consideration for Web API Calls</h2>
<div class="content_block" id="custom_post_widget-4455">While calling APIs you may face some performance issues. There are a few tips you can consider to speed up things.
<h4><span style="font-size: 14pt;"><strong>Use Server-side filtering if possible in URL or Body Parameters</strong></span></h4>
Many API supports filtering your data by URL parameters or via Body. Whenever possible try to use such features.  Here is an example of <a href="http://www.odata.org/getting-started/basic-tutorial/" target="_blank" rel="noopener">odata API</a>, In the below query the first query is faster than the second query because in the first query we filter at the server.
<pre class="lang:tsql decode:true">SELECT * FROM value
WITH(
	 Src='https://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json&amp;$filter=Country eq ''USA'''
	,DataFormat='Odata'
)

-- Slow query - Client-side filtering
SELECT * FROM value
WHERE Country ='USA'
WITH(
	 Src='https://services.odata.org/V3/Northwind/Northwind.svc/Customers?$format=json'
	,DataFormat='Odata'
)</pre>
<h4><span style="font-size: 14pt;"><strong>Avoid Special features in SQL Query (e.g. WHERE, Group By, Order By)</strong></span></h4>
ZappySys API engine triggers client-side processing if special features are used in Query. Following SQL Features will trigger Client-Side processing which is several times slower than server-side processing. So always try to use simple query (Select col1, col2 .... from mytable )
<ul>
 	<li>WHERE Clause</li>
 	<li>GROUP BY Clause</li>
 	<li>HAVING Clause</li>
 	<li>ORDER BY</li>
 	<li>FUNCTIONS (e.g. Math, String, DateTime, Regex... )</li>
</ul>
LIMIT clause does not trigger client-side processing.
<h4><span style="font-size: 14pt;"><strong>Consider using pre-generated Metadata / Cache File</strong></span></h4>
Use META option in WITH Clause to use static metadata (Pre-Generated)There are two more options to speedup query processing time. Check <a href="https://zappysys.com/blog/caching-metadata-odbc-drivers-performance/" target="_blank" rel="noopener">this article</a> for details.
<ol>
 	<li>
<pre class="lang:default decode:true">select * from value WITH( meta='c:\temp\meta.txt' )
--OR--
select * from value WITH( meta='my-meta-name' )
--OR--
select * from value WITH( meta='[ {"Name": "col1",&amp;nbsp;"Type": "String", Length: 100},&amp;nbsp;{"Name": "col2",&amp;nbsp;"Type": "Int32"} ...... ]' )</pre>
</li>
 	<li>Enable Data Caching Options (Found on <strong>Property Grid</strong> &gt; <strong>Advanced</strong> Mode Only )</li>
</ol>
<h4><span style="font-size: 14pt;"><strong>Consider using Metadata / Data Caching Option</strong></span></h4>
ZappySys API drivers support Caching Metadata and Data rows to speed up query processing. If your data doesn't change often then you can enable this option to speed up processing significantly.

Check <a href="https://zappysys.com/blog/caching-metadata-odbc-drivers-performance/" target="_blank" rel="noopener">this article</a> for details how to enable Data cache / metadata cache feature for datasource level or query level.

To define cache option at query level you can use like below.
<pre class="">SELECT * FROM $
WITH 
(  SRC='https://myhost.com/some-api'
  ,CachingMode='All'  --cache metadata and data rows both
  ,CacheStorage='File' --or Memory
  ,CacheFileLocation='c:\temp\myquery.cache'
  ,CacheEntryTtl=300 --cache for 300 seconds
)
</pre>
&nbsp;

&nbsp;
<h4><strong><span style="font-size: 14pt;">Use --FAST Option to enable Stream Mode</span></strong></h4>
ZappySys JSON / XML drivers support <strong>--FAST</strong> suffix for Filter. By using this suffix after Filter driver enables Stream Mode, <a href="https://zappysys.com/blog/caching-metadata-odbc-drivers-performance/#Reading_Large_Files_Streaming_Mode_for_XML_JSON" target="_blank" rel="noopener">Read this article</a> to understand how this works.
<pre class="lang:default decode:true">SELECT * FROM $ 
LIMIT 10 --//add this just to test how fast you can get 10 rows
WITH(
  Filter='$.LargeArray[*]--FAST' --//Adding --FAST option turn on STREAM mode (large files)
 ,SRC='https://zappysys.com/downloads/files/test/large_file_100k_largearray_prop.json.gz'
 --,SRC='c:\data\large_file.json.gz'
 ,IncludeParentColumns='False'  --//This Must be OFF for STREAM mode (read very large files)
 ,FileCompressionType='GZip' --Zip or None (Zip format only available for Local files)
)</pre>
&nbsp;</div>
<h2>Other considerations for Web API calls in JAVA</h2>
<div class="content_block" id="custom_post_widget-3901">There are few settings you can coder while calling Web API
<h3><strong>API Limit / Throttling</strong></h3>
While calling public API or other external web services one important aspect you have to check,  how many requests are allowed by your API. Especially when you use API pagination options to pull many records you have to slow down based on API limits. For example, your API may allow you only 5 requests per second. Use Throttling Tab on Driver UI to set delay after each request.
<h3><strong>2D Array Transformation</strong></h3>
If you are using JSON or XML API Driver then possible you may have to transform your data using 2D array transformation feature. <a href="https://zappysys.com/blog/parse-multi-dimensional-json-array-ssis/" target="_blank" rel="noopener">Check this link</a> for more information.

&nbsp;</div>
<h2></h2>
<h3>Conclusion</h3>
<p>To conclude, in this tutorial, we learned how to access the REST API using Java. We created a ZappySys ODBC connection and then used a ZappySys Gateway to connect to it.</p>
<h3>References</h3>
<ul>
<li><a href="https://zappysys.com/products/odbc-powerpack/download/" target="_blank" rel="noopener">ZappySys ODBC PowerPack</a></li>
<li><a href="https://zappysys.com/onlinehelp/odbc-powerpack/index.htm#page=odbc-integration-programming-java.htm" target="_blank" rel="noopener">Java example ZappySys ODBC PowerPack</a></li>
<li><a href="http://doraprojects.net/blog/?p=1491" target="_blank" rel="noopener">Add connection in Netbeans 8 to the SQL Server 2012 database</a>.</li>
</ul>
<p>The post <a href="https://zappysys.com/blog/connect-java-to-rest-api-json-soap-xml/">How to connect Java to REST API (JSON / SOAP XML)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
