![]() |
VOOZH | about |
The CData JDBC driver for Databricks is easy to integrate with Java Web applications. This article shows how to efficiently connect to Databricks data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for Databricks in Jetty.
Accessing and integrating live data from Databricks has never been easier with CData. Customers rely on CData connectivity to:
While many customers are using CData's solutions to migrate data from different systems into their Databricks data lakehouse, several customers use our live connectivity solutions to federate connectivity between their databases and Databricks. These customers are using SQL Server Linked Servers or Polybase to get live access to Databricks from within their existing RDBMs.
Read more about common Databricks use-cases and how CData's solutions help solve data problems in our blog: What is Databricks Used For? 6 Use Cases.
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
Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the Databricks data source at the level of the Web app, in WEB-INF\jetty-env.xml.
<Configure id='databricksdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="databricksdemo" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg><Ref refid="databricksdemo"/></Arg> <Arg>jdbc/databricksdb</Arg> <Arg> <New class="cdata.jdbc.databricks.DatabricksDriver"> <Set name="url">jdbc:databricks:</Set> <Set name="Server">127.0.0.1</Set> <Set name="Port">443</Set> <Set name="TransportMode">HTTP</Set> <Set name="HTTPPath">MyHTTPPath</Set> <Set name="UseSSL">True</Set> <Set name="User">MyUser</Set> <Set name="Password">MyPassword</Set> </New> </Arg> </New> </Configure>
To connect to a Databricks cluster, set the properties as described below.
Note: The needed values can be found in your Databricks instance by navigating to Clusters, and selecting the desired cluster, and selecting the JDBC/ODBC tab under Advanced Options.
Configure the resource in the Web.xml:
jdbc/databricksdb javax.sql.DataSource Container
You can then access Databricks with a lookup to java:comp/env/jdbc/databricksdb:
InitialContext ctx = new InitialContext();
DataSource mydatabricks = (DataSource)ctx.lookup("java:comp/env/jdbc/databricksdb");
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.
Download a free trial of the Databricks Driver to get started:
Download NowLearn more:
👁 Databricks IconRapidly create and deploy powerful Java applications that integrate with Databricks.