wood burning stoves 2.0*
The moose likes JDBC and the fly likes Oracle User Session ID through JDBC API? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle User Session ID through JDBC API?" Watch "Oracle User Session ID through JDBC API?" New topic
Author

Oracle User Session ID through JDBC API?

Joe Millers
Greenhorn

Joined: Dec 10, 2010
Posts: 6
I would like to get an Oracle session ID in my Java app.

When I say Oracle session ID, I mean the users session ID on the Oracle DB, not the DB SID. For example, I know I can get the users ID by executing "SELECT sys_context('USERENV','SID') from dual;" but rather than executing this query I was wondering if there is an API operation where I can get this info? I've tried all the DatabaseMetaData methods and properties, but it doesn't look like there is a specific API call for this.

The reason for doing this is for tracking users sessions between the app and db layer. It will help identify long running queries and what the user was doing to get long running queries in that specific state.

Please advise.
Joe Millers
Greenhorn

Joined: Dec 10, 2010
Posts: 6
Anyone?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30146
    
150

Joe,
Not in JDBC because this is a database specific concept. It's possible there is a method in the Oracle driver that does it. I think your query route is best.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: Oracle User Session ID through JDBC API?
 
Similar Threads
Hibernate slow on refresh
Tomcat session data bleeding
java.sql.SQLException: ORA-00028: your session has been killed
maximumm cursors exceeded
JasperReports Question (Speed up report generation)