created a ThreadLocal with key of type [oracle.jdbc.driver.AutoKeyInfo$1]
环境:
spring4.3, mybatis3.5.2, ojdbc8_8c(oracle 18c jdbc)
调试状态下退出时,提示:
严重 [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [oracle.jdbc.driver.AutoKeyInfo$1] (value [oracle.jdbc.driver.AutoKeyInfo$1@10289886]) and a value of type [oracle.jdbc.driver.OracleSql] (value [INSERT INTO 某表 (某字段1, 某字段1)
VALUES (?, ?)]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
看提示是个插入语句,此表有主键,为整型,没有使用序列,自己生成的一个数值
警告信息中,AutoKeyInfo来源于: package oracle.jdbc.driver (class AutoKeyInfo extends OracleResultSetMetaData)
分别在以下三块代码中打上断点,以方便查看是哪里调用的
private static final ThreadLocal<OracleSql> SQL_PARSER = new ThreadLocal() {
protected OracleSql initialValue() {
return new OracleSql((DBConversion)null);
}
};
AutoKeyInfo(String var1) {
this.sqlKind = SqlKind.UNINITIALIZED;
this.originalSql = var1;
this.autoKeyType = 0;
}
AutoKeyInfo(String var1, String[] var2) {
this.sqlKind = SqlKind.UNINITIALIZED;
this.originalSql = var1;
this.columnNames = var2;
this.autoKeyType = 1;
}
1. 开始调试,定位到调用处(org\mybatis\mybatis\3.5.2\mybatis-3.5.2-sources.jar!\org\apache\ibatis\executor\statement\PreparedStatementHandler.java),
其中: PreparedStatement.RETURN_GENERATED_KEYS 值 固定为 1 ;

2. 再进入(oracle\oracle-jdbc\18.3\ojdbc8_18c.jar!\oracle\jdbc\driver\PhysicalConnection.class),在此处生成了 AutoKeyInfo对象

上网找AutoKeyInfo对象的作用,没有找到合适的说明,猜测是与表自增长字段有关的,但此处不需要自增长,想着在第1步有分支【if (keyColumnNames == null)】
,如果keyColumnNames不为null,走 connection.prepareStatement(sql, keyColumnNames)会不会产生AutoKeyInfo了?
3. 打开mybatis官网(我是访问的中文: https://mybatis.org/mybatis-3/zh/sqlmap-xml.html#insert_update_and_delete)
找到 insert, update 和 delete部分,看到keyColumn属性,在自己业务层面 dao.xml对应语句的地方,加上: keyColumn = "字段1",再调试
4. 进入到

5. 还是走到了第2步,试着在第3步 keyColumn = "字段1" 再加上 useGeneratedKeys="false", 官网上说明 false是默认值,不设置应该就采用false,但想着加上试一下

6. 进入(connection.prepareStatement(sql)):

此次没有再创建 AutoKeyInfo,退出程序,也没有发现警告信息了
created a ThreadLocal with key of type [oracle.jdbc.driver.AutoKeyInfo$1]的更多相关文章
- tomcat加载时报The web application [/dmscs] created a ThreadLocal with key of type
严重: The web application [/dmscs] created a ThreadLocal with key of type [com.opensymphony.xwork2.inj ...
- The web application [/struts2_0100] created a ThreadLocal with key of type
引用: 严重: The web application [/struts2_0100] created a ThreadLocal with key of type [com.opensymphony ...
- 错误:created a ThreadLocal with key of type ……but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
tomcat reload显示错误:SEVERE: The web application [/Interceptor] created a ThreadLocal with key of type ...
- Class org.apache.struts2.json.JSONWriter can not access a member of class oracle.jdbc.driver.Physica
产生这个错误的原因是因为我的oracle数据库中有一个CLOB字段,查询出来的时候要转换为JSON而报错. Class org.apache.struts2.json.JSONWriter can n ...
- Maven魔法堂:安装Oracle JDBC Driver依赖的那些坑
前言 由于Oracle并没有向公开Maven仓库提供任何Oracle JDBC Driver的Jar包,因此我们无法像MySQL.SQLite等那么轻松直接通过Maven加载依赖. 而手动下载Orac ...
- java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver 错误的解决办法
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver 错误的解决办法 (2011-05-05 16:08:05) 转载▼ ...
- myeclipe eclipse 常遇问题:Some projects cannot be imported 、java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver、The file connot be validate
1.Some projects cannot be imported because they already exist in the workspace 2.Some projects were ...
- 关于Class.forName("oracle.jdbc.driver.OracleDriver");报ClassNotFoundException 的异常
关于try { Class.forName("oracle.jdbc.driver.OracleDriver"); }catch(ClassNotFoundException e) ...
- 【转】Install Oracle Jdbc driver in your Maven local repository
Install Oracle Jdbc driver in your Maven local repository If you are using Oracle, you must first in ...
随机推荐
- Electromagnetic
1. 电磁辐射 2. 电磁频谱 3. 可见光 4. 微波 5. 更多相关链接 1. 电磁辐射 https://en.wikipedia.org/wiki/Electromagnetic_radiati ...
- SpringBoot之基础入门-专题一
SpringBoot之基础入门-专题一 一.Spring介绍 1.1.SpringBoot简介 在初次学习Spring整合各个第三方框架构建项目的时候,往往会有一大堆的XML文件的配置,众多的dtd或 ...
- 使用HttpURLConnection通过post请求服务器时,URLEncode编码的必要性
通过Post提交表单数据时,数据类型为x-www-urlencoded,提交到服务器的数据服务器默认是通过URLEncoder.encode()编码过得,所以服务器处理时会用URLDecoder.de ...
- MD5摘要
MD5简介 MD5即Message-Digest Algorithm 5(信息-摘要算法),属于摘要算法,是一个不可逆过程,就是无论多大数据,经过算法运算后都是生成固定长度的数据,结果使用16进制进行 ...
- listenTo - backbone.js
listenToobject.listenTo(other, event, callback) 让 object 监听 另一个(other)对象上的一个特定事件.不使用other.on(event, ...
- PHP PDO_MYSQL 链式操作 非链式操作类
<?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +-------------------------------------- ...
- Django 学习之用户认证组件auth与User对象
一.auth模块 from django.contrib import auth django.contrib.auth中提供了许多方法,这里主要介绍其中的三个. 1 .authenticate() ...
- 为什么阿里Java规约要求谨慎使用SimpleDateFormat
前言 在阿里Java开发规约中,有强制性的提到SimpleDateFormat 是线程不安全的类 ,在使用的时候应当注意线程安全问题,如下: 其实之前已经介绍过使用JDK1.8的DateTimeFor ...
- 如何:使用 as 和 is 运算符安全地进行强制转换(C# 编程指南)
如何:使用 as 和 is 运算符安全地进行强制转换(C# 编程指南) 由于对象是多态的,因此基类类型的变量可以保存派生类型.若要访问派生类型的方法,需要将值强制转换回该派生类型.不过,在这些情况下, ...
- 初识Prometheus
安装Prometheus Server Prometheus基于Golang编写,编译后的软件包,不依赖于任何的第三方依赖.用户只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prom ...