2023-09-09 12:16:41.176 [Druid-ConnectionPool-Destroy-181260145] ERROR c.a.d.p.DruidDataSource(3078) - abandon connection, owner thread: http-nio-8005-exec-10, connected at : 1694232698110, open stackTrace
at java.lang.Thread.getStackTrace(Thread.java:1559)

2023-09-09 12:16:41.180 [Druid-ConnectionPool-Destroy-181260145] ERROR c.a.d.p.DruidDataSource(3078) - abandon connection, owner thread: http-nio-8005-exec-1, connected at : 1694232696002, open stackTrace
at java.lang.Thread.getStackTrace(Thread.java:1559)

2023-09-09 12:17:10.105 [http-nio-8005-exec-1] ERROR

2023-09-09 12:17:10.107 [http-nio-8005-exec-1] ERROR

2023-09-09 12:17:11.051 [http-nio-8005-exec-10]

druid配置:
removeAbandoned: true
removeAbandonedTimeout: 300
从被获取到开始计时,如果在removeAbandonedTimeout规定的时间内,还没有关闭的话,就自动进行移除处理。druid的开发者增加这个功能的目的是为了自动移除程序员编程过程中忘记close的connection。而如何断定程序员忘记关闭连接,是通过时间来界定的,removeAbandonedTimeout的默认值是5分钟,我看很多产品都把这个值设置为10分钟,也就是说,如果连接从被获取到被关闭超过10分钟,就会被自动移除。
连接因长SQL一直没有执行完,占用超过removeAbandonedTimeout时被移除,然而在移除时报错了,但因移除报错,此连接还是存在连接池,而实际连接又关闭了,后续再继续拿到的时候就报sqlException:connection closed;
参考:
https://www.modb.pro/db/171346
Druid连接池 报错:abandon connection原因分析_wtopps的博客-CSDN博客
方案一:removeAbandoned设置为false或removeAbandonedTimeout调大;
方案二:在数据库的url链接中加&queryTimeout=75