• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1388
  • Last Modified:

Is there any way to get the SPID from JDBC?


We are using sql server 2005 to do some db work, the java application is connecting to it via the open source jtds driver.  I'm logging out the procedure calls and params, I'd also like to get the value of @@SPID (connection ID) in there as well.  But google is not turning up anything, and I don't see it anywhere.  We are also using spring's JdbcTemplate and StoredProcedure class if that helps any.

So is this possible to get the server connection ID from jdbc land, and if so how?  If not, why not?

Connection con = dataSource.getConnection();
con.getSPID(); // no such method ??

Open in new window

  • 2
2 Solutions
you need to get value from the result set


RussoMAAuthor Commented:
right i can run a query to get it, I'm really asking if getSpid() or getProcessId() or getConnectionID() is built into the jdbc api somewhere.

it should be!
no its not

>>If not, why not?
Because Sun decided not to add it. Feel free to submit a feature request or to mail them and ask why -- but if something is not there, it simply is not there.

PS: no points for me here please; objects already answered this one
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now