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 Xero Data from a Connection Pool in Jetty
The Xero JDBC Driver supports connection pooling: This article shows how to connect faster to Xero data from Web apps in Jetty.
The CData JDBC driver for Xero is easy to integrate with Java Web applications. This article shows how to efficiently connect to Xero data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Xero in Jetty.
About Xero Data Integration
Accessing and integrating live data from Xero has never been easier with CData. Customers rely on CData connectivity to:
- Connect to Xero Accounts and both US and Australian Payroll APIs.
- Read, write, update, and delete Xero objects like Customers, Transactions, Invoices, Sales Receipts and more.
- Use SQL stored procedures for actions like adding items to a cart, submitting orders, and downloading attachments.
- Work with accounting, payroll, file, fixed asset, and project data.
Customers regularly integrate their Xero data with preferred tools, like Tableau, Qlik Sense, or Excel, and integrate Xero data into their database or data warehouse.
Getting Started
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 Xero data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='xerodemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="xerodemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="xerodemo"/></Arg> <Arg>jdbc/xerodb</Arg> <Arg> <New class="cdata.jdbc.xero.XeroDriver"> <Set name="url">jdbc:xero:</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>
To connect, set the Schema connection property in addition to any authentication values. Xero offers authentication for private applications, public applications, and partner applications. You will need to set the XeroAppAuthentication property to PUBLIC, PRIVATE, or PARTNER, depending on the type of application configured. To connect from a private application, you will additionally need to set the OAuthAccessToken, OAuthClientId, OAuthClientSecret, CertificateStoreType, CertificateStore, and CertificateStorePassword.
To connect from a public or partner application, you can use the embedded OAuthClientId, OAuthClientSecret, and CallbackURL, or you can register an app to obtain your own OAuth values.
See the "Getting Started" chapter of the help documentation for a guide to authenticating to Xero.
-
Configure the resource in the Web.xml:
jdbc/xerodb javax.sql.DataSource Container -
You can then access Xero with a lookup to java:comp/env/jdbc/xerodb:
InitialContext ctx = new InitialContext(); DataSource myxero = (DataSource)ctx.lookup("java:comp/env/jdbc/xerodb");
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.