pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Ido M. Tamir <tamir@imp.univie.ac.at>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: connection pooling for postgres
Date: Thu, 11 Jan 2007 10:32:37 -0500
Message-ID: <DDFFB849-8615-438C-973B-9C28B99D261C@fastcrypt.com> (raw)
In-Reply-To: <200701111621.44374.tamir@imp.univie.ac.at>
References: <45A64978.3090305@tethyshealth.com>
	<200701111621.44374.tamir@imp.univie.ac.at>

This is another good option.

On 11-Jan-07, at 10:21 AM, Ido M. Tamir wrote:

> On Thursday 11 January 2007 15:28, James Neff wrote:
>> Greetings,
>
>> Where can I find good instructions or a tutorial on how to do  
>> connection
>> pooling for JDBC to a Postgres database on my client?
>
> http://www.mchange.com/projects/c3p0/index.html
>
> c3p0 was designed to be butt-simple to use. Just put the jar file
> [lib/c3p0-0.9.0.jar] in your application's effective CLASSPATH, and  
> make a
> DataSource like this:
>
> import com.mchange.v2.c3p0.*;
>
> ...
>
> ComboPooledDataSource cpds = new ComboPooledDataSource();
> cpds.setDriverClass( "org.postgresql.Driver" ); //loads the jdbc  
> driver
> cpds.setJdbcUrl( "jdbc:postgresql://localhost/testdb" );
> cpds.setUser("dbuser");
> cpds.setPassword("dbpassword");
>
> [Optional] If you want to turn on PreparedStatement pooling, you  
> must also set
> maxStatements and/or maxStatementsPerConnection(both default to 0):
>
> cpds.setMaxStatements( 180 );
>
>  Do whatever you want with your DataSource, which will be backed by a
> Connection pool set up with default parameters. You can bind the  
> DataSource
> to a JNDI name service, or use it directly, as you prefer.
>  When you are done, you can clean up the DataSource you've created  
> like this:
>
> DataSources.destroy( cpds );
>
>  That's it! The rest is detail.
>
> hth
> ido
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org
>




view thread (6+ messages)  latest in thread

Message-ID: <DDFFB849-8615-438C-973B-9C28B99D261C@fastcrypt.com>
Permalink:  ../DDFFB849-8615-438C-973B-9C28B99D261C@fastcrypt.com/
Also on:    postgresql.org/message-id/DDFFB849-8615-438C-973B-9C28B99D261C@fastcrypt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, tamir@imp.univie.ac.at
  Subject: Re: connection pooling for postgres
  In-Reply-To: <DDFFB849-8615-438C-973B-9C28B99D261C@fastcrypt.com>
  References: <45A64978.3090305@tethyshealth.com> <200701111621.44374.tamir@imp.univie.ac.at> <DDFFB849-8615-438C-973B-9C28B99D261C@fastcrypt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox