Legacy JDBC Driver
Dremio provides a JDBC driver that allows client applications to connect to Dremio Cloud. This driver is licensed under Apache-2.0.
You can download the JDBC driver from here. The driver does not require installation.
The legacy Dremio JDBC driver requires Java 11 as of driver version 25.
It is recommended to use the JDBC driver for Arrow Flight SQL, rather than this legacy JDBC driver.
Supported Authentication Methods
- Use personal access tokens. To generate one, see Personal Access Tokens.
- Use JSON Web Tokens (JWT) from an external token provider. To use a JWT, you must have OAuth enabled in Dremio Cloud. For more information about using JWTs, see External Token Providers.
Construct a Connection String for JDBC Applications
If you are using the JDBC driver to connect to Dremio Cloud from a supported client application, refer to the documentation for creating connections from that application.
If you want to start with the base JDBC connection string for your Dremio Cloud project:
-
Click Project Settings in the side navigation bar.
-
Select General Information in the project settings sidebar.
-
Copy the connection string that is in the JDBC Connection field.
To construct a connection string:
-
Set the subprotocol to
jdbc:dremio:
. -
Set the property
direct
equal tosql.dremio.cloud:443
. -
Add one of these types of authentication credentials for connecting from your JDBC client application to Dremio Cloud:
-
Use a personal access token (PAT) in either of the following ways:
-
Set
Use PAT as password when client app does not support OAuthuser
to$token
and use the PAT as the password when the client application does not support OAuth:jdbc:dremio:direct=sql.dremio.cloud:443;user=$token;password=<personal-access-token>;
-
Set
Use PAT as passwordtoken_type
topersonal_access_token
, use the PAT as the password, and setusername
to null when the client application supports OAuth:jdbc:dremio:direct=sql.dremio.cloud:443;token_type=personal_access_token;password=<personal-access-token>;username=;
-
-
Use a JSON Web Token (JWT). You can use a JWT when the tool used with the JDBC driver supports OAuth:
Use a JWTjdbc:dremio:direct=sql.dremio.cloud:443;token_type=jwt;password=<jwt>;username=;
-
-
Set the property
ssl
equal totrue
:ssl=true;
-
Add the ID of the project that you are connecting to:
project_id=<project-id>;
-
(Optional) Route queries to a particular engine in your project, set the property
engine
to the name of an engine:engine=<engine-name>;
Construct a Prepared Statement with Dynamic Parameters
Dremio supports using parameters in prepared statements for SELECT queries.
The parameter marker is ?
in prepared statements. To execute a prepared statement, you must set the parameter marker with one of the supported set methods.
The example below uses the Date type parameter and the setDate
set method. For set methods, the first argument is the index of the parameter marker in the SQL query, starting from 1. This example includes only one parameter marker, and the second argument is the value for the parameter marker. After you set the parameter, you can execute the prepared statement by calling the executeQuery()
method on the prepared statement.
public class HelloWorld {
public static void main(String[] args) {
try (PreparedStatement stmt = getConnection().prepareStatement("SELECT * FROM (values (DATE '2024-02-20'), (null)) AS a(id) WHERE id=?")) {
Date date = Date.valueOf(LocalDate.of(2024, 02, 20));
stmt.setDate(1, date);
try (ResultSet rs = stmt.executeQuery()) {
assertThat(rs.getMetaData().getColumnCount()).isEqualTo(1);
assertThat(rs.next()).isTrue();
assertThat(rs.getDate(1)).isEqualTo(date);
assertThat(rs.next()).isFalse();
}
}
}
}
The example below demonstrates how to reuse the same prepared statement by defining a different set method and parameter value.
Example prepared statement with different set method and parameterspublic class HelloWorld {
public static void main(String[] args) {
try (PreparedStatement stmt = getConnection().prepareStatement("SELECT * FROM (values (DATE '2024-02-20'), (null)) AS a(id) WHERE id=?")) {
Date date = Date.valueOf(LocalDate.of(2024, 02, 20));
stmt.setDate(1, date);
try (ResultSet rs = stmt.executeQuery()) {
assertThat(rs.getMetaData().getColumnCount()).isEqualTo(1);
assertThat(rs.next()).isTrue();
assertThat(rs.getDate(1)).isEqualTo(date);
assertThat(rs.next()).isFalse();
}
stmt.setDate(1, Date.valueOf(LocalDate.of(2025, 02, 20)));
try (ResultSet rs = stmt.executeQuery()) {
assertThat(rs.next()).isFalse();
}
}
}
}
The following example shows how to use more than one parameter in a prepared statement.
Example prepared statement with two parameterspublic class HelloWorld {
public static void main(String[] args) {
try (PreparedStatement stmt = getConnection().prepareStatement("SELECT * FROM (values (1), (2), (null)) AS a(id) WHERE id = ? OR id < ?")) {
stmt.setInt(1, 1);
stmt.setInt(2, 3);
try (ResultSet rs = stmt.executeQuery()) {
assertThat(rs.getMetaData().getColumnCount()).isEqualTo(1);
assertThat(rs.next()).isTrue();
assertThat(rs.getInt(1)).isEqualTo(1);
assertThat(rs.next()).isFalse();
}
}
}
}
Set Methods for Prepared Statements with Parameters
To execute a prepared statement, you must set the parameter marker with one of the supported set methods listed in the table below.
Column Data Type | Supported Set Methods |
---|---|
Integer | setInt(), setShort(), setNull() |
Numeric | setInt(), setShort(), setLong(), setBigDecimal(), setNull() |
Decimal | setShort(), setInt(), setLong(), setBigDecimal(), setNull() |
BigInt | setShort(), setInt(), setLong(), setBigDecimal(), setNull() |
Double | setDouble(), setFloat(), setNull() |
Float | setFloat(), setNull() |
Char | setString(), setNull() |
Varchar | setString(), setNull() |
Boolean | setBoolean(), setNull() |
Time | setTime(), setNull() |
TimeStamp | setTimestamp(), setNull() |
Date | setDate(), setNull() |
VarBinary | setNull(), setBytes() |
Encryption Parameters
To encrypt communication between your JDBC client applications and Dremio Cloud, use the SSL JDBC connection parameters and a fully qualified host name to configure the JDBC connection string and connect to Dremio.
SSL JDBC Connection Parameter | Type | Description | Default Value | Required |
---|---|---|---|---|
disableCertificateVerification | boolean | Controls whether the driver verifies the host certificate against the trust store.
| false | No |
disableHostVerification | boolean | Forces the driver to verify that the host in the certificate is the host being connected to.
| false | No |
ssl | boolean | Forces the client to use an SSL encrypted connection to communicate with the Dremio server.
Note: | false | Yes |
trustStoreType | string | The trustStore type. Accepted value is: JKS PKCS12 The following property only applies to Windows.
| None | No |
trustStore | string | Path to the truststore. If this parameter is not specified, it defaults to Java truststore ( $JAVA_HOME/lib/security/cacerts ) and the trustStorePassword parameter is ignored. | $JAVA_HOME/lib/security/cacerts | No |
useSystemTrustStore | boolean | Bypasses trustStoreType and automatically picks the correct truststore based on the operating system:
| true | No |
trustStorePassword | string | Password to the truststore. | None | No |
SOCKS Proxy Connection Parameters
If you want to connect to Dremio Cloud through a SOCKS proxy, use these connection parameters:
Parameter | Type | Description | Default Value | Required? |
---|---|---|---|---|
socksProxyHost | string | The IP address or hostname of the SOCKS proxy. | N/A | Yes |
socksProxyPort | integer | The port to use on the SOCKS proxy. | 1080 | No |
socksProxyUsername | string | The username to use for connections. | N/A | No |
socksProxyPassword | string | The password to use for connections. | N/A | Only if a username is specified. |
Advanced Parameters
Name | Type | Description | Default Value |
---|---|---|---|
quoting | string | Specifies which type of character to use to delimit values in queries. The value can be BACK_TICK , BRACKET , or DOUBLE_QUOTE . | DOUBLE_QUOTE |
routing_tag | string | When this parameter is set, the specified tag is associated with all queries executed within a session. Rules can check for the presence of a tag with the function "tag()". For more information, see Workload Management. | N/A |
stringColumnLength | string | The maximum length of data in columns of the STRING datatype and of complex datatypes. The range is 1 to 2147483647. | 1024. |