Re: Recommended resource type and settings for J2EE/Glassfish connection pool - Mailing list pgsql-jdbc

From Craig Ringer
Subject Re: Recommended resource type and settings for J2EE/Glassfish connection pool
Date
Msg-id 4D9D2772.5080501@postnewspapers.com.au
Whole thread Raw
In response to Recommended resource type and settings for J2EE/Glassfish connection pool  ("John Lister" <john.lister-ps@kickstone.com>)
List pgsql-jdbc
On 07/04/11 05:51, John Lister wrote:
> Hi, what is the recommended/supported/best resource type to use with a
> J2EE server eg Glassfish for the connection pool? I'm currently using
> javax.sql.ConnectionPoolDataSource with PGSimpleDataSource as the class,
> however I would have thought an XADataSource would be better?

Do you need XA? If you're not doing distributed transactions and using a
distributed transaction manager, the simple data source should be more
than fine.

I'd avoid using the dumb pooling datasource built into the JDBC driver.
You're doing the right thing by using your container's pooling.

I'm using a glassfish-resources.xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application
Server 3.1 Resource Definitions//EN"
"http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
    <!-- Remember to deploy the PostgreSQL JDBC driver to the
application server! -->
    <jdbc-connection-pool
        name="classads-database-pool"
        datasource-classname="org.postgresql.ds.PGSimpleDataSource"
res-type="javax.sql.DataSource"
        max-pool-size="8"  steady-pool-size="2">
            <property name="User" value="xxxx"/>
            <property name="Password" value="xxxx"/>
            <property name="databaseName" value="xxxx"/>
    </jdbc-connection-pool>
    <jdbc-resource enabled="true" jndi-name="jdbc/classads-database"
object-type="user" pool-name="classads-database-pool"/>
</resources>

which is being deployed using 'asadmin add-resources'.

> Also, what settings/parameters would anyone recommend either to the
> connection pool or the driver itself such as statement caching?

Don't stress about it until it becomes a problem. You can tune those
things based on performance measurements once your app is complete
enough that you can profile and load-test it. Trying to do so blind is
probably just premature "optimization".

--
Craig Ringer

pgsql-jdbc by date:

Previous
From: Lew
Date:
Subject: Re: Memory leak ?
Next
From: Guillaume Cottenceau
Date:
Subject: Re: Memory leak ?