java.sql.SQLException: Connection has already been closed

拥有回忆 提交于 2019-12-03 17:25:21

Following configuration worked for me

<Context context="ROOT" debug="0" reloadable="false" useHttpOnly="true" cacheMaxSize="40960" cacheTTL="60000" cachingAllowed="true" antiJARLocking="true">
    <Resource name="XYZ" auth="Container"
            description="Exchange DB Connection"
            dataSourceClassName="org.postgresql.ds.PGSimpleDataSource"
            dataSource.serverName="XXXXX"
            dataSource.databaseName="XXXX"
            dataSource.portNumber="XXXX"
            dataSource.user="xyz"
            dataSource.password="xyz"
            maximumPoolSize="20"
            minimumIdle="5"
            connectionTimeout="300000"
            factory="com.zaxxer.hikari.HikariJNDIFactory"
            registerMbeans="true"
            type="javax.sql.DataSource" />

The key value here is connectionTimeout. The factory which you are currently using has a default timeout, after that it forces session to close.

The connection timeout value above worked for me , for your application scenarios you'll have to experiment a bit to get the right value.

add below value:

removeAbandonedTimeout="600"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!