0
最新版本的tomcat 8.5.11(8.x.x)的行爲與JDBC/DB配置有所不同。 早些時候(至少在7.x.x版本之前),如果MySQL連接失敗,它會很快退出,但現在它會嘗試3次然後退出。這會在服務器放棄數據庫連接並響應客戶端之前平均延遲約20秒。我檢查了JDBC配置參數,但似乎沒有任何東西可以減少這種延遲。任何想到這一點,表示讚賞。當數據庫關閉時,Tomcat 8的響應速度很慢
<Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxTotal="1000" maxIdle="30" maxWaitMillis="100"
name="jdbc/mydb" password="mypass" type="javax.sql.DataSource" username="myname"
url="jdbc:mysql://localhost:3306/mydb?autoReconnect=true&characterEncoding=UTF-8"/>