Query Lakebase Data in DataGrip
DataGrip is a database IDE that allows SQL developers to query, create, and manage databases. When paired with the CData JDBC Driver for Lakebase, DataGrip can work with live Lakebase data. This article shows how to establish a connection to Lakebase data in DataGrip and use the table editor to load Lakebase data.
Create a New Driver Definition for Lakebase
The steps below describe how to create a new Data Source in DataGrip for Lakebase.
- In DataGrip, click File -> New > Project and name the project
- In the Database Explorer, click the plus icon () and select Driver.
- In the Driver tab:
- Set Name to a user-friendly name (e.g. "CData Lakebase Driver")
- Set Driver Files to the appropriate JAR file. To add the file, click the plus (), select "Add Files," navigate to the "lib" folder in the driver's installation directory and select the JAR file (e.g. cdata.jdbc.lakebase.jar).
- Set Class to cdata.jdbc.lakebase.Lakebase.jar
Additionally, in the advanced tab you can change driver properties and some other settings like VM Options, VM environment, VM home path, DBMS, etc - For most cases, change the DBMS type to "Unknown" in Expert options to avoid native SQL Server queries (Transact-SQL), which might result in an invalid function error
- Click "Apply" then "OK" to save the Connection
Configure a Connection to Lakebase
- Once the connection is saved, click the plus (), then "Data Source" then "CData Lakebase Driver" to create a new Lakebase Data Source.
- In the new window, configure the connection to Lakebase with a JDBC URL.
Built-in Connection String Designer
For assistance in constructing the JDBC URL, use the connection string designer built into the Lakebase JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.lakebase.jarFill in the connection properties and copy the connection string to the clipboard.
To connect to Databricks Lakebase, start by setting the following properties:- DatabricksInstance: The Databricks instance or server hostname, provided in the format instance-abcdef12-3456-7890-abcd-abcdef123456.database.cloud.databricks.com.
- Server: The host name or IP address of the server hosting the Lakebase database.
- Port (optional): The port of the server hosting the Lakebase database, set to 5432 by default.
- Database (optional): The database to connect to after authenticating to the Lakebase Server, set to the authenticating user's default database by default.
OAuth Client Authentication
To authenicate using OAuth client credentials, you need to configure an OAuth client in your service principal. In short, you need to do the following:
- Create and configure a new service principal
- Assign permissions to the service principal
- Create an OAuth secret for the service principal
For more information, refer to the Setting Up OAuthClient Authentication section in the Help documentation.
OAuth PKCE Authentication
To authenticate using the OAuth code type with PKCE (Proof Key for Code Exchange), set the following properties:
- AuthScheme: OAuthPKCE.
- User: The authenticating user's user ID.
For more information, refer to the Help documentation.
- Set URL to the connection string, e.g.,
jdbc:lakebase:DatabricksInstance=lakebase;Server=127.0.0.1;Port=5432;Database=my_database;InitiateOAuth=GETANDREFRESH;
- Click "Apply" and "OK" to save the connection string
At this point, you will see the data source in the Data Explorer.
Execute SQL Queries Against Lakebase
To browse through the Lakebase entities (available as tables) accessible through the JDBC Driver, expand the Data Source.
To execute queries, right click on any table and select "New" -> "Query Console."
In the Console, write the SQL query you wish to execute. For example:
SELECT ShipName, ShipCity FROM Orders WHERE ShipCountry = 'USA'
Download a free, 30-day trial of the CData JDBC Driver for Lakebase and start working with your live Lakebase data in DataGrip. Reach out to our Support Team if you have any questions.