Ready to get started?

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

 Download Now

Learn more:

EnterpriseDB Icon EnterpriseDB JDBC Driver

Rapidly create and deploy powerful Java applications that integrate with EnterpriseDB.

Connect to EnterpriseDB Data from a Connection Pool in Jetty



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

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

    <Configure id='enterprisedbdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="enterprisedbdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="enterprisedbdemo"/></Arg> <Arg>jdbc/enterprisedbdb</Arg> <Arg> <New class="cdata.jdbc.enterprisedb.EnterpriseDBDriver"> <Set name="url">jdbc:enterprisedb:</Set> <Set name="User">postgres</Set> <Set name="Password">admin</Set> <Set name="Database">postgres</Set> <Set name="Server">127.0.0.1</Set> <Set name="Port">5444</Set> </New> </Arg> </New> </Configure>

    The following connection properties are required in order to connect to data.

    • Server: The host name or IP of the server hosting the EnterpriseDB database.
    • Port: The port of the server hosting the EnterpriseDB database.

    You can also optionally set the following:

    • Database: The default database to connect to when connecting to the EnterpriseDB Server. If this is not set, the user's default database will be used.

    Connect Using Standard Authentication

    To authenticate using standard authentication, set the following:

    • User: The user which will be used to authenticate with the EnterpriseDB server.
    • Password: The password which will be used to authenticate with the EnterpriseDB server.

    Connect Using SSL Authentication

    You can leverage SSL authentication to connect to EnterpriseDB data via a secure session. Configure the following connection properties to connect to data:

    • SSLClientCert: Set this to the name of the certificate store for the client certificate. Used in the case of 2-way SSL, where truststore and keystore are kept on both the client and server machines.
    • SSLClientCertPassword: If a client certificate store is password-protected, set this value to the store's password.
    • SSLClientCertSubject: The subject of the TLS/SSL client certificate. Used to locate the certificate in the store.
    • SSLClientCertType: The certificate type of the client store.
    • SSLServerCert: The certificate to be accepted from the server.
  4. Configure the resource in the Web.xml:

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

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.