jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Multiple connections (Was: Jackrabbit, the database)
Date Tue, 21 Aug 2007 14:57:50 GMT
Hi,

On 8/21/07, Thomas Mueller <thomas.tom.mueller@gmail.com> wrote:
> Reusing prepared statements is harder with pooled connections. In JDK
> 1.6, thanks to javax.sql.StatementEventListener, they can if the
> connection pool manager supports it. In JDK 1.4 and 1.5, I am not sure
> what / when connection pool managers can reuse them.

If we did use a pooled DataSource, then I'd preferably drop all the
long-lived prepared statements that are currently kept as member
variables by the database persistence managers. Individual persistence
methods would become something like this:

    void foo() throws ... {
        Connection connnection = datasource.getConnection();
        try {
            PreparedStatement ps = connection.prepareStatement(...);
            try {
                // use the prepared statement
            } finally {
                ps.close();
            }
        } finally {
            connection.close();
        }
    }

Any reasonable connection pool will pool also the prepared statements,
so the above code would normally only require an extra hash lookup and
some bookkeeping overhead.

BR,

Jukka Zitting

Mime
View raw message