Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfAJC-0006F2-3w for pgsql-jdbc@arkaria.postgresql.org; Tue, 17 Nov 2020 23:22:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kfAIf-0005a3-JL for pgsql-jdbc@arkaria.postgresql.org; Tue, 17 Nov 2020 23:22:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfAIf-0005Zw-A9 for pgsql-jdbc@lists.postgresql.org; Tue, 17 Nov 2020 23:22:13 +0000 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kfAIc-0007Vh-GG for pgsql-jdbc@lists.postgresql.org; Tue, 17 Nov 2020 23:22:12 +0000 Received: by mail-io1-xd42.google.com with SMTP id j12so40022iow.0 for ; Tue, 17 Nov 2020 15:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=vt9UlNgLbAOIvDCNA12NduV/3Cs/eg/oBxEf60DgIHM=; b=J9bzNzJh65/1v5VkSLmDirQ4wcz6Ze+dxfcGL3aEPcoUGhb8q0NAoGziJgeJr7MCX5 I4p65yTlQmYMGbRo5gGb59JY6dLpPeTmIh4zkvEStXm4YEg8tirUw9VN8OtNOWDy/4no Car7QmDuwWRSOEA5XVbSgUCZz6meLyiYiZBY4wPM5dvA8AfmEgRUFsEh1DphG9S7klzu ODeDdxEUneUhguYZj21FtCgvj3lRuOGTQLqaL8paU5a0JETUUc7+2PUkugJoDwziz+gh Qc7wqL+y8Z8M2zC8Eyzfw7LOv3vXYT+TuiyzJcNF0E6ov8AoCO34Lq3AWZJp0AvSQjsU H3sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=vt9UlNgLbAOIvDCNA12NduV/3Cs/eg/oBxEf60DgIHM=; b=W88seSeQ3XwQHmzNB/+ZkOVzGj0tQH5fCz9fJLttFUT6z7qs+ZHa3WsKPjt4zPTD7j uwDGNI/QxDXI8GVpGVG8P1NveWh6P7qEMsK6svLxP32HfKOIkbRSZA3254cytbOx+494 +t3FP6t8kP/lnnb054RiOIb7K4itrdaEs1sNzNHMoxKktMnVkic1Zj9Uv+Vcg3HqFh6S 84ulHy1C/Q8fdjBeypzY0hx8VfuHeCSUnn7CHZxjiZ+aofLk5I9qaGFALEldkEpNdxu+ o+7sQjCRiVOBEkG/s3D8lXC6CwnFyCBv7HOREq3rMtf9E2uj6Ud492jkLzoYIeeGIdlb XTRQ== X-Gm-Message-State: AOAM532PcG06IVjBb4NjhYGlW69n14f8qe3UpdaCgTHKDqZNiNtpKG7j WVVNAnzUyPDIM5jlarA0JdX/q4XK+n0= X-Google-Smtp-Source: ABdhPJyA7P0iVlwAxPYnDLm7YZ9+f78a9g0GjXMm0NDFkOqFj7Q49IJ8hERqJjQXbVEsJqxtCWe46A== X-Received: by 2002:a5d:9c02:: with SMTP id 2mr13680935ioe.28.1605655328495; Tue, 17 Nov 2020 15:22:08 -0800 (PST) Received: from ?IPv6:2601:681:5500:dde0:d8a4:2cd1:b962:ca9b? ([2601:681:5500:dde0:d8a4:2cd1:b962:ca9b]) by smtp.gmail.com with ESMTPSA id b15sm14513831ilg.83.2020.11.17.15.22.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Nov 2020 15:22:08 -0800 (PST) Subject: Re: embeded tomcat and correct DataSource. To: Dave Cramer , Rob Bygrave Cc: "pgsql-jdbc@lists.postgresql.org" References: <0f62f2cb-7474-0af5-3bbe-c3747c079dcb@gmail.com> From: Rob Sargent Message-ID: Date: Tue, 17 Nov 2020 16:22:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------D120E7F56A448184F844A7E4" Content-Language: en-CA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------D120E7F56A448184F844A7E4 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 11/17/20 4:04 PM, Dave Cramer wrote: > > On Tue, 17 Nov 2020 at 17:57, Rob Bygrave > 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! --------------D120E7F56A448184F844A7E4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit


On 11/17/20 4:04 PM, Dave Cramer wrote:

On Tue, 17 Nov 2020 at 17:57, Rob Bygrave <robin.bygrave@gmail.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



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!


    


--------------D120E7F56A448184F844A7E4--