Ready to get started?

Download a free trial of the Sage 50 UK Driver to get started:

 Download Now

Learn more:

Sage 50 UK Icon Sage 50 UK JDBC Driver

Complete read-write access to Sage 50 UK enables developers to search (Customers, Transactions, Invoices, Sales Receipts, etc.), update items, edit customers, and more, from any Java/J2EE application.

Connect to Sage 50 UK Data from a Connection Pool in Jetty



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

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

    <Configure id='sageukdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="sageukdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="sageukdemo"/></Arg> <Arg>jdbc/sageukdb</Arg> <Arg> <New class="cdata.jdbc.sage50uk.Sage50UKDriver"> <Set name="url">jdbc:sage50uk:</Set> <Set name="URL">http://your-server:5493/sdata/accounts50/GCRM/your-address</Set> <Set name="User">Manager</Set> </New> </Arg> </New> </Configure>

    Note: Only Sage 50 UK 2012 and above are supported.

    The User and Password properties, under the Connection section, must be set to valid Sage 50 UK user credentials. These values will be the same used to log in to the Sage 50 UK software.

    Additionally, the URL property, under the Connection section, will need to be set to the address of the company dataset desired. To obtain the address, do the following:

    1. If you have not already done so, open the Sage 50 UK software.
    2. Click Tools -> Internet Options.
    3. Select the SData Settings tab.
    4. Click the Details button next to Sage 50 Accounts. A window is displayed containing a list of company names along with the address to their corresponding datasets.
    5. Set the URL property to the value in the address field next to the company desired.
  4. Configure the resource in the Web.xml:

    jdbc/sageukdb javax.sql.DataSource Container
  5. You can then access Sage 50 UK with a lookup to java:comp/env/jdbc/sageukdb: InitialContext ctx = new InitialContext(); DataSource mysageuk = (DataSource)ctx.lookup("java:comp/env/jdbc/sageukdb");

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.