Обсуждение: Recommended resource type and settings for J2EE/Glassfish connection pool

Поиск
Список
Период
Сортировка

Recommended resource type and settings for J2EE/Glassfish connection pool

От
"John Lister"
Дата:
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?
 
I seem to remember a while ago trying it but having quite a few problems so gave up, but want to look at this again from a performance point of view.
 
 
Also, what settings/parameters would anyone recommend either to the connection pool or the driver itself such as statement caching?
 
Thanks
 
John
--
 
Got needs? Get Goblin'! - http://www.pricegoblin.co.uk/

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

От
Craig Ringer
Дата:
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