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"/>