Connect to JDBC drivers

Learn how to connect a JDBC driver to Retool.

You can connect a JDBC driver to Retool and make it available as a resource in Retool. Once complete, your users can write queries that interact with your data.

Requirements

All users for Retool organizations on Free or Team plans have global Edit permissions and can add, edit, and remove resources. If your organization manages user permissions for resources, you must be a member of a group with Edit all permissions.

Cloud users are only be able to select from a global list of drivers. If the driver you want to use is missing, contact Retool Support.

Self-hosted JDBC configuration changes

Self-hosted users need to make some configuration changes on their Retool instance to use a JDBC resource.

1. Update Retool to the latest build

Run ./update_retool.sh on your host machine to update Retool.

2. Add your JDBC .jar files

On the host machine, create a jdbc/ folder and add the JDBC .jar files to it. Include any .jar dependencies that your files need.

3. Mount Volumes

In the docker-compose.yml file, add:

- `./jdbc:/retool_backend/jdbc`

to the volume sections for api, db-connector, and db-ssh-connector.

4. Add a folder path for the ENV Variable

In the docker.env file, add JDBC_DIRECTORY_PATH=/retool_backend/jdbc to provide a path to the JDBC .jar files.

5. Restart Retool

On your host machine, run sudo docker-compose up -d to restart Retool.

1. Create a new resource

Sign in to your Retool organization and navigate to the Resources tab. Click Create new, then select Resource.

Create a new resource

2. Select the resource type

Retool can connect to almost any API or database, and has built-in integrations for popular data sources. Select the JDBC resource type.

Select the resource type

3. Configure the resource

Specify a name and location for the JDBC resource. Retool displays the resource name and type in query editors to help users identify them. Next, configure the required settings.

Credentials

Cloud users need to set:

SettingDescription
Driver nameThe name of the JDBC driver class you want to use.
Connection stringThe connection string for your resource.

Self-hosted users need to set:

SettingDescription
Driver nameThe name of the JDBC driver class you want to use.
Connection stringThe connection string for your resource.
Schema queryA query that retrieves your database schemas.

Configure the resource

Click Test Connection to verify that Retool can connect to your JDBC resource. If the test fails, check the resource settings and try again. Testing a connection only checks whether Retool can successfully connect to the resource. It cannot check whether the provided credentials have sufficient privileges or can perform every supported action.

Schema query

For schemas to render in the query editor, the schema query must return the following four columns: column_name, data_type, table_name, and table_schema. The schemas are not required to connect to your resource, but they're often helpful to have. You can run your schema query against your resource to verify that it returns the correct information.

4. Save the resource

Click Create resource to complete the setup. You can then click either Create an app to immediately start building a Retool app or Back to resources to return to the list of resources.

Save the resource

Wrap up

Your JDBC resource is now ready to use. To interact with your data, select the resource in the query editor. You can read data using SQL queries, write data using GUI queries (if enabled), and use the schema browser to search tables or columns.