We are proud to share our inclusion in the 2024 Gartner Magic Quadrant for Data Integration Tools. We believe this recognition reflects the differentiated business outcomes CData delivers to our customers.
Get the Report →Connect to Adobe Commerce Data from a Connection Pool in Jetty
The Adobe Commerce JDBC Driver supports connection pooling: This article shows how to connect faster to Adobe Commerce data from Web apps in Jetty.
The CData JDBC driver for Adobe Commerce is easy to integrate with Java Web applications. This article shows how to efficiently connect to Adobe Commerce data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Adobe Commerce in Jetty.
Configure the JDBC Driver for Salesforce as a JNDI Data Source
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
- Add the CData and license file, located in the lib subfolder of the installation directory, into the lib subfolder of the context path.
-
Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the Adobe Commerce data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='adobecommercedemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="adobecommercedemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="adobecommercedemo"/></Arg> <Arg>jdbc/adobecommercedb</Arg> <Arg> <New class="cdata.jdbc.adobe commerce.Adobe CommerceDriver"> <Set name="url">jdbc:adobe commerce:</Set> <Set name="OAuthClientId">MyConsumerKey</Set> <Set name="OAuthClientSecret">MyConsumerSecret</Set> <Set name="CallbackURL">http://127.0.0.1:33333</Set> <Set name="Url">https://myAdobe Commercehost.com</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>
Adobe Commerce uses the OAuth 1 authentication standard. To connect to the Adobe Commerce REST API, you will need to obtain values for the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties by registering an app with your Adobe Commerce system. See the "Getting Started" section in the help documentation for a guide to obtaining the OAuth values and connecting.
You will also need to provide the URL to your Adobe Commerce system. The URL depends on whether you are using the Adobe Commerce REST API as a customer or administrator.
Customer: To use Adobe Commerce as a customer, make sure you have created a customer account in the Adobe Commerce homepage. To do so, click Account -> Register. You can then set the URL connection property to the endpoint of your Adobe Commerce system.
Administrator: To access Adobe Commerce as an administrator, set CustomAdminPath instead. This value can be obtained in the Advanced settings in the Admin menu, which can be accessed by selecting System -> Configuration -> Advanced -> Admin -> Admin Base URL.
If the Use Custom Admin Path setting on this page is set to YES, the value is inside the Custom Admin Path text box; otherwise, set the CustomAdminPath connection property to the default value, which is "admin".
-
Configure the resource in the Web.xml:
jdbc/adobecommercedb javax.sql.DataSource Container -
You can then access Adobe Commerce with a lookup to java:comp/env/jdbc/adobecommercedb:
InitialContext ctx = new InitialContext(); DataSource myadobecommerce = (DataSource)ctx.lookup("java:comp/env/jdbc/adobecommercedb");
More Jetty Integration
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.