Ready to get started?

Download a free trial of the Dynamics 365 Business Central Driver to get started:

 Download Now

Learn more:

Dynamics 365 Business Central (NAV) Icon Dynamics 365 Business Central JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Dynamics 365 Business Central account data including Items, Sales Orders, Purchase Orders, and more!

Connect to Dynamics 365 Business Central Data from a Connection Pool in Jetty

The Dynamics 365 Business Central JDBC Driver supports connection pooling: This article shows how to connect faster to Dynamics 365 Business Central data from Web apps in Jetty.

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.

Configure the JDBC Driver for Salesforce as a JNDI Data Source

Follow the steps below to connect to Salesforce from Jetty.

  1. 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
  2. Add the CData and license file, located in the lib subfolder of the installation directory, into the lib subfolder of the context path.
  3. 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=""> <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"></Set> </New> </Arg> </New> </Configure>

    To authenticate to Dynamics 365 Business Central, you must provide the User and AccessKey properties.

    To obtain the User and AccessKey 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 User and AccessKey connection string properties. Note that the User Name is not your email address. It is a shortened user name.

    To connect to data, specify OrganizationUrl. If you have multiple companies in your organization, you must also specify the Company to indicate which company you would like to connect to. Company does not need to be specified if you have only one company.

  4. Configure the resource in the Web.xml:

    jdbc/d365businesscentraldb javax.sql.DataSource Container
  5. 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");

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.