Re: Recommended resource type and settings for J2EE/Glassfish connection pool

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: John Lister <john(dot)lister-ps(at)kickstone(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Recommended resource type and settings for J2EE/Glassfish connection pool
Date: 2011-04-07 02:54:42
Message-ID: 4D9D2772.5080501@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Guillaume Cottenceau 2011-04-07 07:05:19 Re: Memory leak ?
Previous Message Lew 2011-04-06 22:40:36 Re: Memory leak ?