![]() |
VOOZH | about |
The CData JDBC driver for Dynamics 365 Business Central is easy to integrate with Java Web applications. This article shows how to efficiently connect to Dynamics 365 Business Central data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Dynamics 365 Business Central 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 Dynamics 365 Business Central data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='d365businesscentraldemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="d365businesscentraldemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="d365businesscentraldemo"/></Arg> <Arg>jdbc/d365businesscentraldb</Arg> <Arg> <New class="cdata.jdbc.d365businesscentral.D365BusinessCentralDriver"> <Set name="url">jdbc:d365businesscentral:</Set> <Set name="OrganizationUrl">https://myaccount.financials.dynamics.com/</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>
To authenticate to Dynamics 365 Business Central, you must select an AuthScheme and provide the required properties (OAuth by default).
Specify the . If you have multiple companies in your organization, you must also specify the to indicate which company you would like to connect to. does not need to be specified if you have only one company.
To authenticate with an Access Key, set AuthScheme to "AccessKey" and provide the and properties.
To obtain the and values, navigate to the Users page in Dynamics 365 Business Central and then click on Edit. The User Name and Web Service Access Key values are what you will enter as the and connection string properties. Note that the User Name is not your email address. It is a shortened user name.
If you wish to authenticate through other methods, refer to the Help documentation.
Configure the resource in the Web.xml:
jdbc/d365businesscentraldb javax.sql.DataSource Container
You can then access Dynamics 365 Business Central with a lookup to java:comp/env/jdbc/d365businesscentraldb:
InitialContext ctx = new InitialContext();
DataSource myd365businesscentral = (DataSource)ctx.lookup("java:comp/env/jdbc/d365businesscentraldb");
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 Dynamics 365 Business Central Driver to get started:
Download NowLearn more:
👁 Dynamics 365 Business Central (NAV) IconRapidly create and deploy powerful Java applications that integrate with Dynamics 365 Business Central account data including Items, Sales Orders, Purchase Orders, and more!