1 Reply Latest reply on Sep 27, 2001 3:51 PM by David Jencks

    PreparedStatement w/ Pool

    Jason Vasquez Newbie

      I know that using a PreparedStatement improves performance since the DB backend only has to compile the SQL one time. But, does this work with a pool? Are PreparedStatements tied to a particular connection? I have a servlet which uses the JBoss db pools...should I just create a new PreparedStatement each time I get a connection, or is it safe to cache one at the class level?

        • 1. Re: PreparedStatement w/ Pool
          David Jencks Master

          Prepared statements are most definitely tied to a connection. Since in jboss you can't hold onto a connection over transaction boundaries, holding onto a prepared statement will do you even less good. Some drivers implement prepared statement caching themselves.

          However, note that if you are using XADataSourceLoader with the XADataSourceImpl or ConnectionFactoryLoader with the jdbc (local transaction, not xa) wrapper, the jboss wrappers do prepared statement pooling for you.