![]() |
VOOZH | about |
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.
Accessing and integrating live data from Xero has never been easier with CData. Customers rely on CData connectivity to:
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.
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 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. 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");
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 Xero Driver to get started:
Download NowLearn more:
👁 Xero IconComplete read-write access to Xero accounting enables developers to search (Customers, Transactions, Invoices, Sales Receipts, etc.), update items, edit customers, and more, from any Java/J2EE application.