Connect to Oracle Eloqua Reporting Data from a Connection Pool in Jetty
The CData JDBC driver for Oracle Eloqua Reporting is easy to integrate with Java Web applications. This article shows how to efficiently connect to Oracle Eloqua Reporting data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Oracle Eloqua Reporting in Jetty.
Configure the JDBC Driver for Salesforce as a JNDI Data Source
Follow the steps below to connect to Salesforce from Jetty.
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
- Add the CData and license file, located in the lib subfolder of the installation directory, into the lib subfolder of the context path.
-
Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the Oracle Eloqua Reporting data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='eloquareportingdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="eloquareportingdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="eloquareportingdemo"/></Arg> <Arg>jdbc/eloquareportingdb</Arg> <Arg> <New class="cdata.jdbc.oracleeloquareporting.OracleEloquaReportingDriver"> <Set name="url">jdbc:oracleeloquareporting:</Set> <Set name="AuthScheme">Basic</Set> <Set name="User">user</Set> <Set name="Password">password</Set> <Set name="Company">MyCompany</Set> </New> </Arg> </New> </Configure>Oracle Eloqua Reporting supports the following authentication methods:
- Basic authentication (User and Password)
- OAuth 2.0 code grant flow
- OAuth 2.0 password grant flow
Basic Authentication (User and Password)
To perform authentication with a user and password, specify these properties:
- AuthScheme: Basic.
- Company: The company name associated with your Oracle Eloqua Reporting account.
- User: Your login account name.
- Password: Your login password.
OAuth Authentication (Code Grant Flow)
To authenticate with the OAuth code grant flow, you must set AuthScheme to OAuth and create a custom OAuth application. For information about how to create a custom OAuth application, see the Help documentation.
Then set the following properties:
- InitiateOAuth: GETANDREFRESH. Used to automatically get and refresh the OAuthAccessToken.
- OAuthClientId: The client Id assigned when you registered your application.
- OAuthClientSecret: The client secret that was assigned when you registered your application.
- CallbackURL: The redirect URI that was defined when you registered your application.
When you connect, the driver opens Oracle Eloqua Reporting's OAuth endpoint in your default browser. Log in and grant permissions to the application. When the access token expires, the driver refreshes it automatically.
OAuth Authentication (Password Grant Flow)
With the OAuth password grant flow, you can use your OAuth application's credentials alongside your user credentials to authenticate without the need to grant permission manually via a browser prompt. You must create an OAuth app (see the Help documentation) to use this authentication method.
Set the following properties:
- AuthScheme: OAuthPassword
- Company: The company's unique identifier.
- User: Your login account name.
- Password: Your login password.
- OAuthClientId: The client Id assigned when you registered your custom OAuth application.
- OAuthClientSecret: The client secret assigned when you registered your custom OAuth application.
-
Configure the resource in the Web.xml:
jdbc/eloquareportingdb javax.sql.DataSource Container
-
You can then access Oracle Eloqua Reporting with a lookup to java:comp/env/jdbc/eloquareportingdb:
InitialContext ctx = new InitialContext(); DataSource myeloquareporting = (DataSource)ctx.lookup("java:comp/env/jdbc/eloquareportingdb");
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.