Search code examples
javajdbcsap-asejtds

Can I change the 'appName' on an already open JTDS connection?


I'm looking for a way to pass web-application transaction information on to the underlying database process. In my Java code I might have a transactional method ReservationService#search(), which runs one or several SQLs. On the DBMS I just see a SPID along with some locks. I'm looking for a way to add a tag "ReservationService#search" to the database process.

jTDS / Sybase ASE have an appName which can be passed in as a connection property. As we're using a connection pool, existing connections are re-used, but to my knowledge the appName is only read on establishing a new connection.

How can I re-set the appName on an already existing connection (without closing/opening)? Or, if that simply is impossible, are there any other ideas to get transactional context information from Java to the DBMS?

  • Tomcat Webapplication (Java 6)
  • C3P0 Connection Pool (only supports JDBC 3)
  • jTDS connecting to Sybase ASE 15

Thanks Simon


Solution

  • Unfortunately not, it seems that you can only specify that in the URL parameters when you open up the connection but can't be altered afterwords.

    You can aways pass in a SessionID of some kind from your Java/Tomecat to all your Sybase queries. For me, this was easy as I use stored procedures for all communications between my Java application and the SQL server. I based my SessionID in Java on the J2EE session.