Java API reference for the Databricks JDBC Driver (OSS)
This article provides API reference documentation for the Databricks JDBC Driver (OSS).
IDatabricksConnection interface
Describes methods to retrieve connection and statement execution handles.
Package: com.databricks.jdbc.api
getStatement |
---|
IDatabricksStatement getStatement(String statementId) throws SQLException
Returns a handle for a given statement ID. Returns: An IDatabricksStatement to handle an existing execution. |
getConnectionId |
---|
String getConnectionId() throws SQLException
Returns a handle for the session connection. Returns: A String that represents the connection for the underlying session of the execution. |
IDatabricksDriver interface
Describes methods to manage the driver connection.
Package: com.databricks.client.jdbc
com.databricks.client.jdbc.Driver
extends com.databricks.client.jdbc.IDatabricksDriver
and java.sql.Driver
.
closeConnection |
---|
void closeConnection(String url, Properties info, String connectionId) throws SQLException
Closes the connection for the specified connection ID and JDBC connection URL. Returns: None |
IDatabricksResultSet interface
Describes methods to retrieve results of an asynchronous query.
Package: com.databricks.jdbc.api
getExecutionStatus |
---|
IExecutionStatus getExecutionStatus() throws SQLException
Returns the status of the execution. Returns: An IExecutionStatus that represents the status of the execution |
getStatementId |
---|
String getStatementId() throws SQLException
Returns the associated statement-id of the async execution. Returns: A String that is the statement ID of the execution |
IDatabricksStatement interface
Describes methods to execute and handle an asynchronous query.
Package: com.databricks.jdbc.api
executeAsync |
---|
ResultSet executeAsync(String sql) throws SQLException
Executes a SQL command in asynchronous mode. Parameters:
sql - the command to execute.
Returns: A ResultSet that represents the results of the executed SQL |
getExecutionResult |
---|
ResultSet getExecutionResult() throws SQLException
Fetches a status and response for an already executed SQL command, and throws error if no command has been executed. This method can be called multiple times to poll execution status. Returns: A ResultSet that represents the results of the executed SQL |
IDatabricksVolumeClient interface
Describes methods to manage files in Unity Catalog volumes.
Package: com.databricks.jdbc.api
prefixExists |
---|
boolean prefixExists(String catalog, String schema, String volume, String prefix, boolean caseSensitive) throws SQLException
Determines if a specific prefix (folder-like structure) exists in the Unity Catalog volume. The prefix must be a part of the file name. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the Unity Catalog volume name of the cloud storage.
prefix - the prefix to check for existence along with the relative path from the volume as the root directory.
caseSensitive - whether the check should be case-sensitive or not.
Returns: A boolean indicating whether the prefix exists or not. |
objectExists |
---|
boolean objectExists(String catalog, String schema, String volume, String objectPath, boolean caseSensitive) throws SQLException
Determines if a specific object (file) exists in the Unity Catalog volume. The object must match the file name exactly. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the Unity Catalog volume name of the cloud storage.
objectPath - the path of the object (file) from the volume as the root directory to check for existence within the volume (inside any sub-folder).
caseSensitive - a boolean indicating whether the check should be case-sensitive or not.
Returns: A boolean indicating whether the object exists or not. |
volumeExists |
---|
boolean volumeExists(String catalog, String schema, String volumeName, boolean caseSensitive) throws SQLException
Determines if a specific volume exists in the given catalog and schema. The volume must match the volume name exactly. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volumeName - the name of the volume to check for existence.
caseSensitive a boolean indicating whether the check should be case sensitive or not.
Returns: A boolean indicating whether the volume exists or not. |
listObjects |
---|
List<String> listObjects(String catalog, String schema, String volume, String prefix, boolean caseSensitive) throws SQLException
Returns the list of all filenames in the Unity Catalog volume that start with a specified prefix. The prefix must be a part of the file path from the volume as the root. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the UC volume name of the cloud storage.
prefix - the prefix of the filenames to list. This includes the relative path from the volume as the root directory.
caseSensitive - a boolean indicating whether the check should be case-sensitive or not.
Returns: A list of strings indicating the filenames that start with the specified prefix. |
getObject (file) |
---|
boolean getObject(String catalog, String schema, String volume, String objectPath, String localPath) throws SQLException
Retrieves an object (file) from the Unity Catalog volume and stores it in the specified local path. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the UC volume name of the cloud storage.
objectPath - the path of the object (file) from the volume as the root directory.
localPath - the local path where the retrieved data is to be stored.
Returns: A boolean value indicating status of the GET operation. |
getObject (stream) |
---|
InputStreamEntity getObject(String catalog, String schema, String volume, String objectPath) throws SQLException
Retrieves an object as an input stream from the Unity Catalog volume. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the UC volume name of the cloud storage.
objectPath - the path of the object (file) from the volume as the root directory.
Returns: An instance of the input stream entity. |
putObject (file) |
---|
boolean putObject(String catalog, String schema, String volume, String objectPath, String localPath, boolean toOverwrite) throws SQLException
Uploads data from a local path to a specified path within a Unity Catalog volume. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the UC volume name of the cloud storage.
objectPath the destination path where the object (file) is to be uploaded from the`volume as the root directory.
localPath the local path from where the data is to be uploaded.
toOverwrite a boolean indicating whether to overwrite the object if it already exists.
Returns: A boolean value indicating the status of the PUT operation. |
putObject (stream) |
---|
boolean putObject(String catalog, String schema, String volume, String objectPath, InputStream inputStream, long contentLength, boolean toOverwrite) throws SQLException
Uploads data from an input stream to a specified path within a Unity Catalog volume. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the UC volume name of the cloud storage.
objectPath - the destination path where the object (file) is to be uploaded from the volume as the root directory.
inputStream - the input stream from where the data is to be uploaded.
contentLength - the length of the input stream.
toOverwrite a boolean indicating whether to overwrite the object if it already exists.
Returns: A boolean value indicating status of the PUT operation. |
deleteObject |
---|
boolean deleteObject(String catalog, String schema, String volume, String objectPath) throws SQLException
Removes an object from a specified path within a Unity Catalog volume. Parameters:
catalog - the catalog name of the cloud storage.
schema - the schema name of the cloud storage.
volume - the UC volume name of the cloud storage.
objectPath - the path of the object (file) from the volume as the root directory to delete.
Returns: A boolean value indicating the status of the DELETE operation. |
ExecutionState enum
Contains the states of an executing asynchronous query.
Package: com.databricks.jdbc.api
RUNNING
| The statement is running on the server |
---|
PENDING
| The statement is yet to run on the server |
SUCCEEDED
| The statement ran successfully |
FAILED
| The statement execution failed |
ABORTED
| The statement was aborted |
CLOSED
| The statement has been closed |
IExecutionStatus interface
Describes methods to retrieve the status of an asynchronous query.
Package: com.databricks.jdbc.api
getExecutionState |
---|
ExecutionState getExecutionState() throws SQLException
Returns the state of the execution status. Returns: An ExecutionState that represents the state of the execution status |
getSqlState |
---|
String getSqlState() throws SQLException
If it is set, returns the SQLState code for a failed status. Returns: A String that is the SQLState code |
getErrorMessage |
---|
String getErrorMessage() throws SQLException
Returns the error message of a failed execution. Returns: A String that is the error message. |