Java MySQL语句取消计时器无法停止

Java MySQL语句取消计时器无法停止,java,mysql,tomcat,Java,Mysql,Tomcat,以下警告的原因是什么 WARNING: The web application [TI] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. Apr 28, 2016 1

以下警告的原因是什么

WARNING: The web application [TI] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Apr 28, 2016 11:03:25 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [TI] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:503)
java.util.TimerThread.mainLoop(Timer.java:526)
java.util.TimerThread.run(Timer.java:505)
每当我更改代码并重新启动tomcat时,就会发生这种情况。 我正在创建
mysql
连接,我想我正在正确地关闭它。
这是我的密码

@RequestMapping(value = "/file/md5", method = RequestMethod.POST)
public ResponseEntity<?> md5Status(@RequestParam(required = true) String filename) {

    Connection con = SqlUtility.getMysqlConnection(host, port, database,username, password);
    SqlUtility.closeDbInstances(SqlUtility.mysqlConnection);
    SqlUtility.closeDbInstances(con);
    return new ResponseEntity<>(HttpStatus.CONFLICT);
}
(旧问题,但我遇到了相同的错误/警告消息) 您是否将jdbc池与
QueryTimeoutInterceptor
一起使用,或者调用
语句.setQueryTimeout(320)
函数。它调用内部mysqljdbc.jar线程来取消长时间运行的查询

Tomcat hotdeployment无法识别它,所以线程被甩在后面运行,并在RAM中保留一个死掉的webapp上下文

  <Resource name="jdbc/BSManager" auth="Container" 
    type="javax.sql.DataSource" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    initialSize="2" maxActive="100" maxIdle="10" maxWait="30000"    
    username="myuser" password="mypwd"
    driverClassName="com.mysql.jdbc.Driver" 
    jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor(queryTimeout=320)"
    url="jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&amp;characterEncoding=utf8"
        validationQuery="SELECT 1" removeAbandoned="true" removeAbandonedTimeout="7200"
        testOnBorrow="true" maxAge="1800000"
  />

你在tomcat库中有mysql连接器jar吗?没有必要吗?是的,在tomcat库中添加连接器jar,然后再试一次,让我知道。没有。它仍然向我发出同样的警告。我不认为这是jar缺失的问题,因为在这种情况下,异常可能是
ClassNotFound
类型。
  <Resource name="jdbc/BSManager" auth="Container" 
    type="javax.sql.DataSource" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    initialSize="2" maxActive="100" maxIdle="10" maxWait="30000"    
    username="myuser" password="mypwd"
    driverClassName="com.mysql.jdbc.Driver" 
    jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor(queryTimeout=320)"
    url="jdbc:mysql://127.0.0.1:3306/mydb?useUnicode=true&amp;characterEncoding=utf8"
        validationQuery="SELECT 1" removeAbandoned="true" removeAbandonedTimeout="7200"
        testOnBorrow="true" maxAge="1800000"
  />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" 
        classesToInitialize="com.mysql.jdbc.NonRegisteringDriver" />