3 Replies Latest reply on Sep 11, 2001 5:32 PM by davidjencks

    Does JBoss cache PreparedStatements?

    toddh

      I read that Weblogic now caches PreparedStatements and was wondering if JBoss does.

      If not, are there any plans to add this?

        • 1. Re: Does JBoss cache PreparedStatements?
          davidjencks

          jboss has cached prepared statements since at least feb 2001. There has been some discussion, however, that this may not be always appropriate since a well designed db driver could cache prepared statements in a more appropriate way for the particular database, and 2 caches might possibly interfere with each other.

          • 2. Re: Does JBoss cache PreparedStatements?
            lolsson

            How does one code stateless session beans to benefit
            from this caching?

            Can I write my business methods so that they release
            connections and statements as soon as they are
            done with them? Something like this:

            public void BM(...) throws .....{
             Connection c = mydatasource.getConnection();
             PreparedStatement s = c.prepare("select ...");
             ....
             ... use <s> ....
             ....
             s.close();
             c.close();
            }
            



            • 3. Re: Does JBoss cache PreparedStatements?
              davidjencks

              well, close the result set(if any) too. In fact, you _must_ close connections before the transaction commits in jboss, and get new ones after the start of the next transaction, in order to assure enrollment in the correct transaction.