![]() |
VOOZH | about |
The CData JDBC driver for IBM Cloud Object Storage is easy to integrate with Java Web applications. This article shows how to efficiently connect to IBM Cloud Object Storage data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for IBM Cloud Object Storage in Jetty.
Follow the steps below to connect to Salesforce from Jetty.
Enable the JNDI module for your Jetty base. The following command enables JNDI from the command-line:
java -jar ../start.jar --add-to-startd=jndi
Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the IBM Cloud Object Storage data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='ibmcloudobjectstoragedemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="ibmcloudobjectstoragedemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="ibmcloudobjectstoragedemo"/></Arg> <Arg>jdbc/ibmcloudobjectstoragedb</Arg> <Arg> <New class="cdata.jdbc.ibmcloudobjectstorage.IBMCloudObjectStorageDriver"> <Set name="url">jdbc:ibmcloudobjectstorage:</Set> <Set name="ApiKey">myApiKey</Set> <Set name="CloudObjectStorageCRN">MyInstanceCRN</Set> <Set name="Region">myRegion</Set> <Set name="OAuthClientId">MyOAuthClientId</Set> <Set name="OAuthClientSecret">myOAuthClientSecret</Set> </New> </Arg> </New> </Configure>
If you do not already have Cloud Object Storage in your IBM Cloud account, follow the procedure below to install an instance of SQL Query in your account:
There are certain connection properties you need to set before you can connect. You can obtain these as follows:
To connect with IBM Cloud Object Storage, you need an API Key. You can obtain this as follows:
If you have multiple accounts, specify the CloudObjectStorageCRN explicitly. To find the appropriate value, you can:
You can now set the following to connect to data:
When you connect, the connector completes the OAuth process.
Configure the resource in the Web.xml:
jdbc/ibmcloudobjectstoragedb javax.sql.DataSource Container
You can then access IBM Cloud Object Storage with a lookup to java:comp/env/jdbc/ibmcloudobjectstoragedb:
InitialContext ctx = new InitialContext();
DataSource myibmcloudobjectstorage = (DataSource)ctx.lookup("java:comp/env/jdbc/ibmcloudobjectstoragedb");
The steps above show how to configure the driver in a simple connection pooling scenario. For more use cases and information, see the Working with Jetty JNDI chapter in the Jetty documentation.
Download a free trial of the IBM Cloud Object Storage Driver to get started:
Download NowLearn more:
👁 IBM Cloud Object Storage IconRapidly create and deploy powerful Java applications that integrate with IBM Cloud Object Storage.