wood burning stoves 2.0*
The moose likes JDBC and the fly likes Regarding java.sql.Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Regarding java.sql.Connection" Watch "Regarding java.sql.Connection" New topic
Author

Regarding java.sql.Connection

Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Hi All,
Can i know at a specific place in my code that either a connection object is associated with any resultset or statement?
I mean have this connection created any statement and either that statement has opened any resultset?
Jeffrey Hunter
Ranch Hand

Joined: Apr 16, 2004
Posts: 305
Look at the Java APIs, specifically, Statement, ResultSet - here.
You can use getConnection() to retrieve the Connection object associated with a given Statement.
Similarly, you can use getStatement to identify the Statement object associated with a particular ResultSet.
[ May 10, 2004: Message edited by: Jeffrey Hunter ]
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Hi Jeffrey Hunter,
Thanks for your reply. But i only have the connection object and no information about any statement or resultset object. I want to know through that object whether any statement or resultset is associated with it or i can just close that connection without any worry.
Jeffrey Hunter
Ranch Hand

Joined: Apr 16, 2004
Posts: 305
I can't think of anything using the Connection object itself, but what you might want to look at is the underlying database. I often use the Oracle adminstrator tool to monitor database connections. I don't know off-hand how to access this data using JDBC (it will probably be a simple SQL query to list open connections to the database). I don't think you'll be able to get any info from the Connection object itself.
You should be keeping tight control over your Connection objects, so you might want to look at your design, and ask yourself why you're addressing this problem. Perhaps a better design will solve the issue.
[ May 10, 2004: Message edited by: Jeffrey Hunter ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding java.sql.Connection