• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding java.sql.Connection

 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic