Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 04:28 AM
I am trying to use the Databricks JDBC Spark Driver to run sql queries on the SQL Warehouse
Sample connection String
String TOKEN = "<token>";
String HTTP_PATH = "/sql/1.0/warehouses/<sql-warehouse-id>";
final String connStr = "jdbc:spark://discover.cloud.databricks.com:443/default;" +
"TransportMode=http;SSL=1;" +
"HTTPPath=" + HTTP_PATH + ";" +
"AuthMech=11;" +
"Auth_Flow=0;" +
"Auth_AccessToken=" + TOKEN + ";";
try {
final Connection connection = DriverManager.getConnection(connStr);
final Statement statement = connection.createStatement();
final ResultSet rset = statement.executeQuery("SELECT count(*) FROM table_name limit 10");
int columnCount = rset.getMetaData().getColumnCount();
while (rset.next()) {
for (int i = 1; i <= columnCount; i++) {
System.out.print(rset.getString(i) + "\t");
}
System.out.println();
}
connection.close();
} catch (SQLException e) {
System.err.println(e);
}
Above code is always running two SQL on the Warehouse
1. Listing columns 'catalog : Spark, schemaPattern : <schema_name>, tablePattern : <table_name>, columnName : null' -- Take 15+ sec everytime
2. Actual query
I tried reusing the connection object it didn't work. Any idea what going on here?
Using Driver Version: 2.6.18