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语句取消计时器无法停止相关推荐
- mysql 餐饮管理系统_Java Mysql 餐饮管理系统 过程心得记录
------------------------------------------Have a Good Day~---------------------------------- 准备国赛和AC ...
- java mysql 唯一约束_java MySQL约束
# 今日内容 1. DQL:查询语句 1. 排序查询 2. 聚合函数 3. 分组查询 4. 分页查询 2. 约束 3. 多表之间的关系 4. 范式 5. 数据库的备份和还原 # DQL:查询语句 1. ...
- mysql 表情符_java+mysql对于表情符的处理
出错环境: mysql 5.0:utf8编码 jdbc:mysql-connector-java-5.1.5-bin.jar 在有表情符的情况下报错: java.sql.SQLException: I ...
- MySQL综合测评_java+mysql生综合素质测评系统设计与实现
摘要随着科技水平的不断提高,许多工作都在计算机系统的帮助下在不断地发展和进步.使用日趋成熟的计算机技术来替代传统的人工手动模式,是当今社会不可逆转的必然趋势.计算机已进入人类社会的各个领域,发挥着越来 ...
- java mysql重连_java mysql
关于 java mysql的搜索结果 问题 连接mysql错误,Druid-ConnectionPool-Create-1641320886 16:52:01.163 [Druid-Connectio ...
- mysql时区时间戳_Java MySQL时间戳时区问题
时区只是查看日期的不同方式(这是一个固定的时间点).我在这里写了一个小例子(密切关注断言): // timezone independent date (usually interpreted by ...
- java mysql语句_java mysql查询语句怎么写
展开全部 1:使用SHOW语句找出在服务器上当前存在什么数据32313133353236313431303231363533e4b893e5b19e31333363373766库: mysql> ...
- 摘录来自mysql 5.1的手册 关于mysql的事务处理和锁定语句
START TRANSACTION, COMMIT和ROLLBACK语法 START TRANSACTION | BEGIN [WORK] COMMIT [WORK] [AND [NO] CHAIN] ...
- mysql load xml_MySQL的SQL语句 - 数据操作语句(10)- LOAD XML 语句
LOAD XML 语句 1. LOAD XML 2. [LOW_PRIORITY | CONCURRENT] [LOCAL] 3. INFILE 'file_name' 4. [REPLACE | I ...
最新文章
- 在Linux中如何禁止用户登录
- Xcode11 上传苹果卡在Authenticating with the iTunes store 或者transpoter上传卡在正在验证 APP - 正在通过App Store进行认证
- iPhone X的刘海基本上就是一台Kinect
- 周五话营销 | 数据分析强势解决营销人三大痛点
- 在做TLS/SSL时报错
- python集成工具包_pyBit
- Android官方开发文档Training系列课程中文版:分享文件之获取文件信息
- html纵向固定导航菜单代码,jQuery和css3响应式垂直固定导航菜单插件
- 工业互联网智能智造-工业企业大数据汇聚通道-产品设计
- SpringBoot启动时实现自动执行代码的几种方式讲解
- 贪小便宜的人交不得,否则,可能会因小失大
- mooc中习题--简单运算器
- window自动备件软件
- 同是共享内存,shm_open与shmget有什么差异?
- jeb安装教程_JEB2插件教程之一
- duet二重奏hp_Duet游戏安卓下载|Duet二重奏最新版下载v2.0.4-乐游网安卓下载
- SpringBoot线程池获取service实例空指针
- 数学符号Span的含义
- 期末了,用Python写个自动批改作业系统
- 智能驾驶定位三大发展趋势是什么?
热门文章
- 【机器学习】LBP+SVM实现特征检测
- 在MATLAB中,用Simulink搭建一个二阶传递函数模型
- 几种在Linux下查询外网IP的办法
- OpenGL之GLFW入门学习
- c/c++实现一个密集型server/socket多路复用select
- 2017计算机等级考试题,2017年计算机二级考试题库及答案
- mysql锁的一些理解简书_MySQL锁系列之锁的种类和概念
- centos io 查看程序_centos 查看每天应用程序的iowait
- nysql collation
- springboot源码解析autoconfigure之WebMvcAutoConfiguration