Pergunta

Our webapps currently make JDBC calls to our Oracle database directly. We tag each connection with calls to the DBMS_APPLICATION_INFO package in a static getConnection(String client) method, e.g.

CallableStatement pstmt = conx.prepareCall("{call DMBS_APPLICATION_INFO.SET_CLIENT_INFO(?)}");
pstmt.setString(1, "my client");
pstmt.executeUpdate();

This has proven useful from time to time, and we'd like to continue this when we switch to Spring JDBC.

I think if we made each query a transaction, then make calls to DBMS_APPLICATION_INFO before executing the query (or queries) this would work, but that would require adding the above code to every place we get a connection now. Outside of a transaction it doesn't seem possible because Spring JDBC opens and closes the connection with each query.

In Spring JDBC is there a way to make calls to DBMS_APPLICATION_INFO under the hood like we do now, passing a String with which to tag the connection?

Thanks!

Foi útil?

Solução 2

The answer to my question is no. If I was tackling this issue today I'd probably look at writing an Interceptor for Tomcat's JDBC pool or wrapping the driver. In reality, though, most likely I'd drop the use of DBMS_APPLICATION_INFO. While nice to have it wasn't operationally useful, not worth adding code and complexity for.

Outras dicas

Have you looked into Spring Aspects?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top