cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Administration & Architecture
Explore discussions on Databricks administration, deployment strategies, and architectural best practices. Connect with administrators and architects to optimize your Databricks environment for performance, scalability, and security.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Proper way to collect Statement ID from JDBC Connection

harripy
New Contributor III

Hi, 

We are executing DML calls on Databricks SQL Warehouse programmatically, with Java and Python.

There can be thousands of executions running on daily level, so in case of an error occurs, it would be very beneficial to spot the Statement ID of the failed execution.

We just recently discovered that the Statement ID can be retrieved on Python SDK as follows from the connection cursor:

 

if cursor and cursor.active_op_handle is not None:
    queryId = UUID(bytes= cursor.active_op_handle.operationId.guid)

 

But what would be equivalent for doing the same on Java SDK?

We are getting the Java Connection from the DriverManager.getConnection(jdbcUrl, props) -call.

1 REPLY 1

harripy
New Contributor III

Thanks @Retired_mod for the suggestion, but I still would need the Statement ID for further analysis (as Query History performs best with direct ID). - Any way to Unwrap the java.sql.Connection interface to the implementing class and getting the metadata through it?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group