ERROR [com.alibaba.druid.pool.DruidDataSource] - abandon connection, owner thread: http-apr-8083-exec-25

错误:
[ ERROR] [2015-06-30 15:07:07] com.alibaba.druid.pool.DruidDataSource [2021] - abandon connection, open stackTrace
 

   at java.lang.Thread.getStackTrace(Thread.java:1436)
    at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1014)
    at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544)
    at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661)
    at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:938)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:930)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:102)
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
    at org.hibernate.tool.schema.extract.internal.ExtractionContextImpl.getJdbcConnection(ExtractionContextImpl.java:62)
    at org.hibernate.tool.schema.extract.internal.ExtractionContextImpl.getJdbcDatabaseMetaData(ExtractionContextImpl.java:75)
    at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getTable(InformationExtractorJdbcDatabaseMetaDataImpl.java:198)
    at org.hibernate.tool.schema.extract.internal.legacy.DatabaseInformationImpl.getTableInformation(DatabaseInformationImpl.java:113)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigrationToTargets(SchemaMigratorImpl.java:96)
    at org.hibernate.tool.schema.internal.SchemaMigratorImpl.doMigration(SchemaMigratorImpl.java:59)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129)
    at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:97)

解决方案:
修改该配置文件中如下内容:

       
        
       
将“removeAbandonedTimeout”的时间设置长一点。

原理:
这两个参数的大概意思就是, 

    通过datasource.getConnontion() 取得的连接必须在removeAbandonedTimeout这么多秒内调用close(),要不然druid就会帮关闭连接。

  总结:

    连接池为了防止程序从池里取得连接后忘记归还的情况, 而提供了一些参数来设置一个租期, 使用这个可以在一定程度上防止连接泄漏

    但是如果你的业务真要跑这么久~~~~那还是注意下这个设置.

posted @ 2020-02-05 21:25  LZ太热  阅读(2647)  评论(0编辑  收藏  举报