On Mon, Jun 15, 2015 at 4:42 AM, Jose María Zaragoza <demablo...@gmail.com>
wrote:

> Hello:
>
>
> I'm using Tomcat 7.0.59 and PostgreSQL JDBC driver 9.4-1201-jdbc4
>
> The context.xml settings are
>
>
> <Resource auth="Container" type="javax.sql.DataSource"
>                   factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"

                  driverClassName="org.postgresql.Driver"
>                   initialSize="0"  maxActive="100" maxIdle="20"
> maxWait="10000" mindIdle="0"
>                   name="datasource/bbdd" password="fake"
> removeAbandoned="true"
>
>
> url="jdbc:postgresql://localhost:9999,localhost:5432,localhost:5433/bbdd?LoginTimeout=3&amp;loadBalanceHosts=false"
>                   username="foo" validationQuery="SELECT 1"
> testOnBorrow="true" timeBetweenEvictionRunsMillis="0"/>
>
>
> I've configured JDBC driver in failover mode ( as you can see in URL
> definition )
>
> When I test this configuration ( I stop/start databases but , at
> least, there is one running ) , sometimes I'm getting this error
> message:
>
>
> org.apache.ibatis.exceptions.PersistenceException:
> ### Error querying database.  Cause:
> org.postgresql.util.PSQLException: This connection has been closed.
>
> How is it possible if testOnBorrow="true" and validationQuery="SELECT 1" ?
>

Try setting validationInterval to a lower value.  It defaults to 30s, which
means it will only run the query once per 30s.

http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Tomcat_JDBC_Enhanced_Attributes


> How I can debug if validationQuery is working as I want  ?
>

1.) Start Tomcat, make sure the app is working.
2.) Stop the DB.
3.) Your app should stop working, since it can't get a connection.  Also,
any pooled connections will now be bad.
4.) Start the DB.
5.) Your app should be working again.  If the pool is configured properly
as your app requests connections, it should remove the bad connections and
replace them with new ones.

Dan



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

Reply via email to