0

If I want to set a DBMS property when a transaction is started in the database... how Do I do that!

What I want to do (for example in SQL Server) is set context_info 0xSome-binary-value-for-a-requestId
What this will give me:

  • Tracability on the DBMS side, meaning I can see the origin requestId for any session_id and transaction
  • For example I can use select context_info, someMoreCols from dm_exec_requests (or sys.sysprocesses etc)
  • I can also use Extened Events, where context_info is visible (in this way I can correlate executed SQL Statements back to the appserver)

With "context_info" I have the ability to see the "origin" from Spring Boot and track application server logs etc using the requestId stored in context_info (for other DBMS engines there are "similar" properties/fields that can be use for the above...)

To acomplish the above I have tried using hibernate Interceptor, and methods: afterTransactionBegin(Transaction tx) and afterTransactionCompletion(Transaction tx) but I havn't found a way to grab the JDBC Connection to execute set context_info ...
(hopefully there are more portable way of doing this, meaning without involving hibernate specififc stuff)

Is there anyway to do what I want?
Thanks for any input

0 Answers0