Ready to get started?

Download a free trial of the Dynamics NAV Driver to get started:

 Download Now

Learn more:

Dynamics NAV Icon Dynamics NAV JDBC Driver

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

Connect to Dynamics NAV Data from a Connection Pool in Jetty

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

The CData JDBC driver for Dynamics NAV is easy to integrate with Java Web applications. This article shows how to efficiently connect to Dynamics NAV data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Dynamics NAV 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 NAV data source at the level of the Web app, in WEB-INF\jetty-env.xml.

    <Configure id='dynamicsnavdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="dynamicsnavdemo" class=""> <Arg><Ref refid="dynamicsnavdemo"/></Arg> <Arg>jdbc/dynamicsnavdb</Arg> <Arg> <New class="cdata.jdbc.dynamicsnav.DynamicsNAVDriver"> <Set name="url">jdbc:dynamicsnav:</Set> <Set name="http://myserver:7048"></Set> <Set name="User">myserver\Administrator</Set> <Set name="Password">admin</Set> <Set name="ServerInstance">DYNAMICSNAV71</Set> </New> </Arg> </New> </Configure>

    Before you can connect, OData Services will need to be enabled on the server. Once OData Services are enabled, you will be able to query any Services that are published on the server.

    The User and Password properties, under the Authentication section, must be set to valid Dynamics NAV user credentials. In addition, you will need to specify a URL to a valid Dynamics NAV server organization root and a ServerInstance. If there is not a Service Default Company for the server, you will need to set the Company as well.

  4. Configure the resource in the Web.xml:

    jdbc/dynamicsnavdb javax.sql.DataSource Container
  5. You can then access Dynamics NAV with a lookup to java:comp/env/jdbc/dynamicsnavdb: InitialContext ctx = new InitialContext(); DataSource mydynamicsnav = (DataSource)ctx.lookup("java:comp/env/jdbc/dynamicsnavdb");

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.