日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 定时器停止_java-MySQL语句取消计时器无法停止

發布時間:2025/3/21 数据库 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 定时器停止_java-MySQL语句取消计时器无法停止 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

以下警告的原因是什么?

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);

}

這是實用程序代碼.

public static Connection mysqlConnection = null;

private static PreparedStatement preparedStatement = null;

private static ResultSet resultSet = null;

public static Connection getMysqlConnection(String host, int port, String database, String username,

String password) {

MysqlDataSource mds = null;

try {

if (mysqlConnection == null || mysqlConnection.isClosed()) {

if (database != null && host != null) {

while (mds == null) {

System.out.println("In Loop");

mds = new MysqlDataSource();

mds.setServerName(host);

mds.setPortNumber(port);

mds.setDatabaseName(database);

mds.setUser(username);

mds.setPassword(password);

try {

mysqlConnection = mds.getConnection();

} catch (CommunicationsException e) {

System.out.format(

"Error occurred while trying to get connection with database [%s]. Are your database host [%s] and port [%s] correct? %n%s%n",

database, host, port, e);

mds = null;

// Had to handle for retrying again and again

// This is because your mysql is bind on localhost change it in my.cfg

}

}

} else {

System.out.format(

"Error occurred while trying to get connection with database [%s] with username [%s] and password [%s].

[ATTN] Make sure your DB adapter properties file contains all required attributes. %n",

database, username, password);

}

}

} catch (SQLException e) {

System.out.format(

"Error occurred while trying to get connection at host [%s] with database [%s] with username [%s] and password [%s] %n%s%n",

host, database, username, password, e);

// It might be because of the database privileges which must be grant to access

} catch (RuntimeException e) {

System.out.format("Error occurred while trying to get [%s] Connection %n%s%n", database, e);

}

if (mysqlConnection != null)

System.out.format("[%S] Connection Successfully Created%n", database);

return mysqlConnection;

}

public static void closeDbInstances(Connection con) {

System.out.println("Trying to close Database Connection...");

if (con != null && preparedStatement != null && resultSet != null) {

try {

resultSet.close();

preparedStatement.close();

con.close();

System.out.println("Database Connection Closed");

} catch (SQLException e) {

System.out.println("Error occurred while trying to close Database connection " + e);

}

}

}

總結

以上是生活随笔為你收集整理的mysql 定时器停止_java-MySQL语句取消计时器无法停止的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。