Connect to Trello Data from a Connection Pool in Jetty



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

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

    <Configure id='trellodemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="trellodemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="trellodemo"/></Arg> <Arg>jdbc/trellodb</Arg> <Arg> <New class="cdata.jdbc.trello.TrelloDriver"> <Set name="url">jdbc:trello:</Set> <Set name="APIKey">myApiKey</Set> <Set name="Token">myGeneratedToken</Set> <Set name="InitiateOAuth">GETANDREFRESH</Set> </New> </Arg> </New> </Configure>

    Trello uses token-based authentication to grant third-party applications access to their API. When a user has granted an application access to their data, the application is given a token that can be used to make requests to Trello's API.

    Trello's API can be accessed in 2 different ways. The first is using Trello's own Authorization Route, and the second is using OAuth1.0.

    • Authorization Route: At the moment of registration, Trello assigns an API key and Token to the account. See the Help documentation for information on how to connect via the Authorization route.
    • OAuth Route: Similar to using Authorization, OAuth creates an Application Id and Secret when you create your account. See the Help documentation for information on how to to connect.

  4. Configure the resource in the Web.xml:

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

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.

Ready to get started?

Download a free trial of the Trello Driver to get started:

 Download Now

Learn more:

Trello Icon Trello JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with Trello data including List, Cards, Boards, and more!