Is there any way to get the SPID from JDBC?

Posted on 2009-04-22
Last Modified: 2012-05-06

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

Question by:RussoMA
    LVL 92

    Expert Comment

    you need to get value from the result set


    Author Comment

    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!
    LVL 92

    Accepted Solution

    no its not

    LVL 20

    Assisted Solution

    >>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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    This article describes some very basic things about SQL Server filegroups.
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now