-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Dhaval,

On 7/30/14, 3:42 PM, Dhaval Jaiswal wrote:
> I want to make the connection alive from tomcat to the db server.
> As of now connection is getting closed / terminating might be due
> to network or idle connection.
> 
> Following is my configuration.
> 
> 
> <Resource name="jdbc/DB_NAME" auth="Container"
> type="javax.sql.DataSource" 
> driverClassName="org.postgresql.Driver" 
> url="jdbc:postgresql://IP:PORT/DB_NAME" username="" password="" 
> maxActive="100" maxIdle="20" maxWait="30000" removeAbandoned="true"
> removeAbandonedTimeout="120" logAbandoned="true" />
> 
> 
> <Connector port="8080" protocol="HTTP/1.1" 
> connectionTimeout="20000" redirectPort="8443" />
> 
> I want to ensure that my connection should be alive and henceforth,
> I have added following parameter in above Resource configuration.
> 
> validationQuery="SELECT 1" testOnBorrow=true

That should work.

> However, after searching many forum says that you should add below 
> parameters too. Please advise on it.
> 
> testOnReturn= testWhileIdle= minEvictableIdleTimeMillis 
> timeBetweenEvictionRunsMillis

If your firewall is closing the connection, then it's your firewall
you'll need to adjust.

If you want the connection pool to /tolerate/ the connections being
closed, then setting testOnBorrow="true" with a suitable validation
query should be sufficient.

Note that testOnBorrow will test all connections each time they are
checked-out of the pool. Depending upon the overhead that causes and
the complexity of your database queries, you may observe noticeable
slowdowns by testing on every checkout. You can look into other
options to test connections only at intervals, which will likely
improve performance, but you lose the robustness of testing every
connection on check-out.

If you set testWhileIdle="true", then the connections will be tested
for connectivity even when they are not being used. You will have to
set timeBetweenEvictionRuns to something other than the default which
is -1 (eviction thread disabled). Depending upon the behavior of your
validation query (or validatorClassName for tomcat-pool), checking for
connectivity may or may not keep the connection open.

If the firewall is closing the connections due to inactivity, then a
simple "SELECT 1" every so often should keep them open.

What's best for you depends upon your environment and requirements.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJT2aOLAAoJEBzwKT+lPKRYVXgP/imga5bKjVt9/DgbRcBg3RIz
BFdxjkPjOsmDR+om1VMyhWkrFxvVQTPs2qUMw8WJia2/YPrcL+EF3OF8Ts5zp3aZ
xnrAJgec8h9wF8TU8+scAUTBZ+uivnU49khSdJoIQVEyIqLjdd40GDb4/3TDTkWQ
NAviP4hP/YRo9oBNtMBH/NZzuflx0SchhGBObgnM5FjnLyWo1mQ9N/dNwbnHhnn4
uJDFrnd6gQmUvsrmmoDE8EG8Sk0/y3mv7gY9DBIutTv1L0OGG+gL+Jsr3C4Dmukv
8GqxpRdw76Cn+0uehlXMNa34RhLWRMXrGrYjIpyOzVW7X5u36Cmk+rM1LKf798Md
oKDHDSPSfUbnv69lR1x6z3XEjA5CVRpndtzNHohPabjrk7PZWdpr64yB6mbdyNAC
KC9NsHT2eOK5TaSc1fLuPn/YirQz8lRd812fzaPXj3hyu9hmD9ume/ljUGc3ELlX
hg3tbJKsjFFW/FY/ESyYLaaTotgJ13O+l3vmAaBRgsYl1kzJcc8GjTtvIuG0iF99
pvaq9ynUx/j4gsoJJIWSW7kWDjvJkMwWHZqRXQTEH1LOMLEuPhMqqxSkY3MLTTBO
ttBYv/fQExcrk8/AoLHTOGYpoqz4mh9gdGyg1IAi71AdhYMy33TDJ40LJ1nz5O7r
pYNskycU3exAqhg8PpY/
=0i0Q
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to