Notiz
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Iech unzemellen oder Verzeechnesser ze änneren.
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Verzeechnesser ze änneren.
Note
This page applies to Databricks JDBC driver versions below version 3. For version 3 and above, see Databricks JDBC Driver.
This page describes how to upload, download, and delete files in Unity Catalog volumes using the Databricks JDBC Driver.
Requirements
- Databricks JDBC Driver version 2.6.38 or above
- Native query mode enabled (default). If disabled, add
UseNativeQuery=1orUseNativeQuery=2to your connection string.
For a complete Java example with authentication setup, see Authentication settings for the Databricks JDBC Driver (Simba).
Upload a file
To upload a file, add the StagingAllowedLocalPaths property to your connection string with the path of the file to upload. For multiple source locations, use a comma-separated list (for example, /tmp/,/usr/tmp/).
Important
In multi-tenant environments where users control the JDBC URL (such as BI tools or developer services), set StagingAllowedLocalPaths to a sandbox location or non-existent path. This prevents users from writing arbitrary files and interfering with the service's internal deployment.
To overwrite an existing file, add OVERWRITE to the statement.
// ...
p.put("StagingAllowedLocalPaths", "/tmp/");
Connection conn = DriverManager.getConnection(url, p);
Statement stmt = conn.createStatement();
stmt.executeQuery("PUT '" +
"/tmp/my-data.csv" +
"' INTO '" +
"/Volumes/main/default/my-volume/my-data.csv" +
"' OVERWRITE")
// ...
Download a file
Use GET to download a file from a volume to a local path:
// ...
Connection conn = DriverManager.getConnection(url, p);
Statement stmt = conn.createStatement();
stmt.executeQuery("GET '" +
"/Volumes/main/default/my-volume/my-data.csv" +
"' TO '" +
"/tmp/my-downloaded-data.csv" +
"'")
// ...
Delete a file
Use REMOVE to delete a file from a volume:
// ...
Connection conn = DriverManager.getConnection(url, p);
Statement stmt = conn.createStatement();
stmt.executeQuery("REMOVE '" +
"/Volumes/main/default/my-volume/my-data.csv" +
"'")
// ...