關於tomcat啓動時的警告 :Property maxActive is not used in DBCP2, use maxTotal instead. 和 Property maxWait i

https://bbs.csdn.net/topics/340185527javascript

網站今天放到服務器上好好的,過一天就不能訪問數據庫了,重啓一下tomcat就行了,網上找了說是MySQL對全部鏈接的有效時間默認爲28800秒,正好8小時,高手請幫忙,最好有實例,謝謝java

看你的描述重啓一下tomcat就行了 說明不是mysql 的問題。應該是系統的鏈接池的緣由吧。應該讓系統在獲取鏈接池的連接的時候,判斷下連接是不是活動的。mysql

 

https://cloud.tencent.com/developer/article/1353263web

關於tomcat啓動時的警告 :Property maxActive is not used in DBCP2, use maxTotal instead. 和 Property maxWait i

咱們如今用的tomcat大概都是8.5 或是9.0,這些版本的tomcat內置的DBCP2,和之前老版本如tomcat 7的鏈接池不同,7.0等老版本用的是DBCP。sql

tomcat 7等老版本中,內置鏈接池時 context.xml文件 的默認配置示例:數據庫

<?xml version="1.0" encoding="UTF-8"?> <Context> <Resource name="jdbc/day28" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWaitMillis="10000" username="root" password="root" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/day28"/> </Context>

在老版本的tomcat裏面關於容許的最大鏈接數用maxActive來表示,最大等待延用maxWait來表示apache

咱們如今用的是新版本的tomcat,新版本內置的鏈接池已經升級了,因此若是咱們繼續使用這個配置就會出現以下圖所示警告:tomcat

警告原文以下:服務器

七月 05, 2018 1:55:06 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory [D:\learn\JavaWeb\apache-tomcat\apache-tomcat-9.0.7\webapps\day28_struts2_final] 七月 05, 2018 1:55:06 下午 org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance 警告: Name = day28 Property maxActive is not used in DBCP2, use maxTotal instead. maxTotal default value is 8. You have set value of "100" for "maxActive" property, which is being ignored. 七月 05, 2018 1:55:06 下午 org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance 警告: Name = day28 Property maxWait is not used in DBCP2 , use maxWaitMillis instead. maxWaitMillis default value is -1. You have set value of "10000" for "maxWait" property, which is being ignored. 七月 05, 2018 1:55:06 下午 org.apache.jasper.servlet.TldScanner scanJars 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 七月 05, 2018 1:55:07 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deployment of web application directory [D:\learn\JavaWeb\apache-tomcat\apache-tomcat-9.0.7\webapps\day28_struts2_final] has finished in [1,469] ms

這個警告其實已經把話說的很明白了,既然8.5,9.0tomcat內置的是DBCP2,已經使用 maxTotal來取代maxActive、使用 maxWaitMillis來取代maxWait,app

所以咱們只須要將本身的配置文件中的maxActive替換成maxTotalmaxWait替換成maxWaitMillis便可。

<?xml version="1.0" encoding="UTF-8"?> <Context> <Resource name="jdbc/day28" auth="Container" type="javax.sql.DataSource" maxTotal="100" maxIdle="30" maxWaitMillis="10000" username="root" password="root" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/day28"/> </Context>

警告消失了:

七月 05, 2018 3:26:15 下午 org.apache.catalina.startup.HostConfig undeploy 信息: Undeploying context [/day28_struts2_final] 七月 05, 2018 3:26:15 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory [D:\learn\JavaWeb\apache-tomcat\apache-tomcat-9.0.7\webapps\day28_struts2_final] 七月 05, 2018 3:26:16 下午 org.apache.jasper.servlet.TldScanner scanJars 信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 七月 05, 2018 3:26:16 下午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deployment of web application directory [D:\learn\JavaWeb\apache-tomcat\apache-tomcat-9.0.7\webapps\day28_struts2_final] has finished in [1,087] ms

附上:DBCP2中配置參數詳解連接:http://bsr1983.iteye.com/blog/2092467

本文參考連接以下:https://blog.csdn.net/vr_jia/article/details/74530389

相關文章
相關標籤/搜索