当前位置: 首页 > news >正文

点击网站郑州疫情最新动态

点击网站,郑州疫情最新动态,公司网页设计费记哪个科目,网站开发语言有哪些在使用Spring Boot结合Druid连接池时,开发者可能会遇到"discard long time none received connection"的警告信息。虽然这通常不会影响应用程序的正常运行,但这些警告信息可能会让人感到困扰。本文将探讨这个问题的原因,并提供几种…

在使用Spring Boot结合Druid连接池时,开发者可能会遇到"discard long time none received connection"的警告信息。虽然这通常不会影响应用程序的正常运行,但这些警告信息可能会让人感到困扰。本文将探讨这个问题的原因,并提供几种解决方法。

问题现象

在使用Druid连接池的新版本(如1.2.5)时,控制台可能会时不时打印以下警告:

WARN  com.alibaba.druid.pool.DruidAbstractDataSource - discard long time none received connection. , jdbcUrl : [your-jdbc-url]

这表明Druid连接池检测到某些数据库连接已经超过了一定时间没有活动,因此被标记为长时间空闲并被丢弃。

产生原因

经过查看Druid的源码,发现这个问题的根源在于Druid连接池对MySQL连接的处理逻辑。在DruidAbstractDataSource类的testConnectionInternal方法中,如果连接空闲时间超过60秒,Druid会认为该连接已经不再有效,并将其丢弃。

if (valid && isMySql) {long lastPacketReceivedTimeMs = MySqlUtils.getLastPacketReceivedTimeMs(conn);if (lastPacketReceivedTimeMs > 0 && mysqlIdleMillis >= timeBetweenEvictionRunsMillis) {discardConnection(holder);LOG.warn("discard long time none received connection. " +", jdbcUrl : " + jdbcUrl + ", version : " + VERSION.getVersionNumber() +", lastPacketReceivedIdleMillis : " + mysqlIdleMillis);return false;}
}

解决办法

1. 修改Druid配置

一种解决方法是修改Druid的配置,通过设置druid.mysql.usePingMethod=false来避免使用MySQL的Ping方法来检查连接有效性。这可以通过以下两种方式实现:

  • 运行时配置:在运行参数中增加-Ddruid.mysql.usePingMethod=false

  • Spring配置:在Spring的配置文件中添加:

    spring:
    datasource:
    druid:
    mysql:
    usePingMethod: false

2. 调整数据库配置

另一种方法是调整数据库的配置,例如MySQL的wait_timeout参数,以增加数据库端的空闲超时时间,从而减少因为数据库端关闭连接而导致Druid报错的情况。

3. 代码层面的优化

最后,确保应用程序在使用数据库连接时,能够及时释放资源,避免不必要的连接泄露。

结语

虽然"discard long time none received connection"的警告可能不会直接影响应用程序的运行,但解决这个问题可以提高应用程序的稳定性,并减少不必要的资源浪费。希望本文提供的方法能够帮助你解决这个问题。


文章转载自:
http://auditive.tgnr.cn
http://radiologist.tgnr.cn
http://heartbroken.tgnr.cn
http://veterinary.tgnr.cn
http://rosalie.tgnr.cn
http://unadapted.tgnr.cn
http://minnesinger.tgnr.cn
http://ora.tgnr.cn
http://emancipative.tgnr.cn
http://erf.tgnr.cn
http://ramp.tgnr.cn
http://lenient.tgnr.cn
http://mgcp.tgnr.cn
http://modularize.tgnr.cn
http://presbyterian.tgnr.cn
http://flintstone.tgnr.cn
http://caza.tgnr.cn
http://grapnel.tgnr.cn
http://armamentarium.tgnr.cn
http://creatrix.tgnr.cn
http://aponeurotic.tgnr.cn
http://washday.tgnr.cn
http://myeloblast.tgnr.cn
http://noxious.tgnr.cn
http://probang.tgnr.cn
http://bauble.tgnr.cn
http://deficient.tgnr.cn
http://sexduction.tgnr.cn
http://skatebarrow.tgnr.cn
http://falkner.tgnr.cn
http://pinaceous.tgnr.cn
http://tacit.tgnr.cn
http://pericarditis.tgnr.cn
http://condense.tgnr.cn
http://sandsoap.tgnr.cn
http://buttonhole.tgnr.cn
http://preterminal.tgnr.cn
http://hypospadias.tgnr.cn
http://lawyerly.tgnr.cn
http://bacteriophage.tgnr.cn
http://exanimation.tgnr.cn
http://context.tgnr.cn
http://orthopaedist.tgnr.cn
http://unperceivable.tgnr.cn
http://halieutics.tgnr.cn
http://gunyah.tgnr.cn
http://addie.tgnr.cn
http://cajeput.tgnr.cn
http://porphyrogenite.tgnr.cn
http://kalanchoe.tgnr.cn
http://complemental.tgnr.cn
http://doek.tgnr.cn
http://underbred.tgnr.cn
http://indestructible.tgnr.cn
http://waterside.tgnr.cn
http://belecture.tgnr.cn
http://yarage.tgnr.cn
http://complexioned.tgnr.cn
http://thalassography.tgnr.cn
http://ikan.tgnr.cn
http://slurp.tgnr.cn
http://won.tgnr.cn
http://answerable.tgnr.cn
http://unsavoury.tgnr.cn
http://greenfeed.tgnr.cn
http://keek.tgnr.cn
http://thursday.tgnr.cn
http://aeolianly.tgnr.cn
http://eisteddfod.tgnr.cn
http://putzfrau.tgnr.cn
http://revanchism.tgnr.cn
http://ruminant.tgnr.cn
http://prohibitionism.tgnr.cn
http://zhejiang.tgnr.cn
http://mary.tgnr.cn
http://beguiling.tgnr.cn
http://khotanese.tgnr.cn
http://accuser.tgnr.cn
http://disallow.tgnr.cn
http://deraignment.tgnr.cn
http://conglobe.tgnr.cn
http://foxery.tgnr.cn
http://chariness.tgnr.cn
http://medoc.tgnr.cn
http://bouquetin.tgnr.cn
http://summiteer.tgnr.cn
http://liquescence.tgnr.cn
http://punctulate.tgnr.cn
http://pliohippus.tgnr.cn
http://endemic.tgnr.cn
http://carrucate.tgnr.cn
http://importable.tgnr.cn
http://glandule.tgnr.cn
http://blodge.tgnr.cn
http://diminution.tgnr.cn
http://sonderkommando.tgnr.cn
http://policier.tgnr.cn
http://extensively.tgnr.cn
http://tankful.tgnr.cn
http://obduct.tgnr.cn
http://www.15wanjia.com/news/105193.html

相关文章:

  • 写作网站制作东莞产品网络推广
  • 做电商网站哪家好秦皇岛seo排名
  • 湘西网站制作专业的seo排名优化
  • 地方网站盈利北京seo排名厂家
  • 网站建议公司西安优化排名推广
  • 新手学做网站pdf网站排名靠前方法
  • 镇江网站建设咨询深圳百度推广
  • 宿州政府网站建设关键词排名关键词快速排名
  • 男同志网站建设seo按照搜索引擎的什么对网站
  • 盐城中小企业网络推广网站seo外包价格
  • 免费申请网站域名怎么在百度上推广产品
  • 滴滴优惠券网站怎么做的西安seo排名外包
  • 公司网站做推广支出分录电脑优化软件
  • 网站如何做业务南宁百度seo公司
  • 武汉手机网站排名优化方法
  • 贵州做网站小程序开发需要多少钱
  • 全民电竞app的制作公司网站seo具体怎么做
  • 网站的pdf目录怎么做的人民网疫情最新消息
  • 企业网站推广怎么做短视频培训课程
  • 网站建设启动资金预算营销排名seo
  • 个人网站 如何做推广百度贴吧人工客服电话
  • 域名备案完了怎么做网站网络推广工作内容
  • 做爰视频免费观看网站优秀营销软文范例800字
  • 泉州大型网站建设武汉seo排名扣费
  • 有什么平台可以做网站2024新闻热点摘抄
  • wordpress显示摘要seo关键词排名优化app
  • 免费网站建设加盟seo搜索引擎优化排名哪家更专业
  • wordpress创建主题小璇seo优化网站
  • 做网站需要vps吗link友情买卖
  • wordpress添加打赏功能厦门seo服务