Re: embeded tomcat and correct DataSource.

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: Dave Cramer <davecramer(at)postgres(dot)rocks>, Rob Bygrave <robin(dot)bygrave(at)gmail(dot)com>
Cc: "pgsql-jdbc(at)lists(dot)postgresql(dot)org" <pgsql-jdbc(at)lists(dot)postgresql(dot)org>
Subject: Re: embeded tomcat and correct DataSource.
Date: 2020-11-17 23:22:07
Message-ID: dd7bb079-7123-c0b1-7cec-a4f3807b2f54@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


On 11/17/20 4:04 PM, Dave Cramer wrote:
>
> On Tue, 17 Nov 2020 at 17:57, Rob Bygrave <robin(dot)bygrave(at)gmail(dot)com
> <mailto:robin(dot)bygrave(at)gmail(dot)com>> wrote:
>
> Hi,
>
> Sorry I'm probably mis-interpreting your question. Hopefully the
> comments below are useful.
>
>
> /> I should use the PGConnectionPoolDataSource if I wish to use
> Apache connection pool mechanism./
>
> In short, I'm pretty sure the answer is no.
>
> The longer answer is, PGPoolingDataSource is the DataSource
> implementation provided in pgjdbc. PGPoolingDataSource is
> */deprecated/* with the comment below and noting that
> PGPoolingDataSource uses PGConnectionPoolDataSource (as an
> implementation detail).  We could think
> of PGConnectionPoolDataSource as part of the DataSource
> implementation provided with postgresql jdbc driver that is marked
> as deprecated (with the suggestion that we migrate to any other
> third party DataSource implementation).
>
> * @deprecated Since 42.0.0, instead of this class you should use a
> fully featured connection pool
>
> * like HikariCP, vibur-dbcp, commons-dbcp, c3p0, etc.
>
>
>
> Any third party javax.sql.DataSource implementation would be
> extremely unlikely to use anything in the /org.postgresql.ds/
> package including PGConnectionPoolDataSource.
>
>
> Rob,
>
> Thanks for catching this. I mis-read the question.
>
> Rob is correct! Do not use the PGPooling source for anything. It is
> really there for completeness. There are so many other good pooling
> implementations it just does not make sense for us to re-implement one.
>
> Dave Cramer
> www.postgres.rocks
>
>

Yes, that was corrected after I posted before I got /anything/ to work.

current wiring is:

ContextResource contextResource =new ContextResource();

contextResource.setName("jdbc/sgsdb");
contextResource.setType("javax.sql.DataSource");
contextResource.setProperty("url","jdbc:postgresql://localhost:5432/version4007");
contextResource.setProperty("driverClassName","org.postgresql.Driver");
contextResource.setProperty("username","postgres");
contextResource.setProperty("password","notnull");
contextResource.setProperty("testWhileIdle","false");
contextResource.setProperty("testOnBorrow","true");
contextResource.setProperty("validationQuery","SELECT 1");
contextResource.setProperty("testOnReturn","false");
contextResource.setProperty("validationInterval","30000");
contextResource.setProperty("timeBetweenEvictionRunsMillis","30000");
contextResource.setProperty("maxActive","50");
contextResource.setProperty("initialSize","5");
contextResource.setProperty("maxWait","10000");
contextResource.setProperty("removeAbandonedTimeout","60");
contextResource.setProperty("minEvictableIdleTimeMillis","30000");
contextResource.setProperty("minIdle","3");
contextResource.setProperty("logAbandoned","true");
contextResource.setProperty("removeAbandoned","true");

contextResource.setProperty("factory","org.apache.tomcat.jdbc.pool.DataSourceFactory");
ctx.getNamingResources().addResource(contextResource);

where ctx is the webapp context.

Thanks for reading!

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2020-11-18 13:23:11 [pgjdbc/pgjdbc] e5e906: fix: Postgres version 14 changes the returned PSQL...
Previous Message Dave Cramer 2020-11-17 23:21:34 Re: embeded tomcat and correct DataSource.