Ready to get started?

Download a free trial of the MYOB AccountRight Driver to get started:

 Download Now

Learn more:

MYOB AccountRight Icon MYOB AccountRight JDBC Driver

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

Connect to MYOB AccountRight Data from a Connection Pool in Jetty

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

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

    <Configure id='myobaccountrightdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="myobaccountrightdemo" class=""> <Arg><Ref refid="myobaccountrightdemo"/></Arg> <Arg>jdbc/myobaccountrightdb</Arg> <Arg> <New class="cdata.jdbc.myob.MYOBDriver"> <Set name="url">jdbc:myob:</Set> <Set name="OAuthClientId">YourClientId</Set> <Set name="OAuthClientSecret">YourClientSecret</Set> <Set name="CompanyFileId">yourCompanyFileId</Set> <Set name="CallbackURL">http://localhost:33333</Set> <Set name="User">companyFileUser</Set> <Set name="Password">companyFilePassword</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>

    These properties are required when connecting to a company file (both for Cloud and On-Premise instances).

    • CompanyFileId: You can find this by starting MYOB, opening your data file, and selecting Help -> About MYOB
    • User: The username associated with your company file.
    • Password: The password associated with your company file.

    Connecting to a Cloud Instance

    To connect to a cloud instance of MYOB, you can use the embedded OAuth credentials or create an OAuth app with MYOB. This process is detailed in the Help documentation.

    Connecting to an On-Premise instance:

    When connecting to an on-premise instance, you will need to set the following connection property in addition to those above:

    • InitiateOauth: Set this to OFF.
    • Url: The Url of your MYOB instance.
  4. Configure the resource in the Web.xml:

    jdbc/myobaccountrightdb javax.sql.DataSource Container
  5. You can then access MYOB AccountRight with a lookup to java:comp/env/jdbc/myobaccountrightdb: InitialContext ctx = new InitialContext(); DataSource mymyobaccountright = (DataSource)ctx.lookup("java:comp/env/jdbc/myobaccountrightdb");

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.