1 Reply Latest reply on Sep 19, 2007 11:13 AM by Steven Ostrowski

    Can you get the active Statement object from a Connection ob

    Steven Ostrowski Newbie


      I'm using JBoss 4.0.3, with Oracle 9iR2 DB, with Oracle 11g JDBC Drivers.

      I'm using a JBoss datasource to the Oracle DB.

      I have the need to call Statement.cancel() on the currently running JDBC Statement, but from a thread that does not have visibility of the Statement object.

      I have visibility of the Connection object, but there is not a standard JDBC API to retrieve the currently executing Statements from that Connection. I'm wondering if there's a JBoss-specific way to retrieve the active Statement from a given Connection?

      Basically, what I want to do is:
      Use my session manager that keeps one connection per session. Then, when a new thread comes in, look up that session's Connection, view its active Statements (probably just one), and then call Statement.cancel() on those statements.

        • 1. Re: Can you get the active Statement object from a Connectio
          Steven Ostrowski Newbie

          As a follow-up for future searchers:

          We had to customize our own code to store a reference to the Statement and then try to cancel() it from the separate thread.

          That worked but then the original Statement hung on the close() method.

          What we had to do, using Oracle, was to store the Oracle session ID of the executing thread, then issue a separate call to the DB to kill that session.

          It's a shame that didn't work in JDBC, as that appears to be the point of Statement.cancel(). Maybe it's Oracle-only JDBC implementation, but I could not find much general info on the web.