This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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 ]
Joined: Mar 18, 2004
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.
Joined: Apr 16, 2004
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 ]