Mybatis异常:java.lang.NumberFormatException: For input string: "S"
MyBatis异常日志如下:
Caused by: java.lang.NumberFormatException: For input string: "S"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at org.apache.ibatis.ognl.OgnlOps.doubleValue(OgnlOps.java:243)
at org.apache.ibatis.ognl.OgnlOps.compareWithConversion(OgnlOps.java:100)
at org.apache.ibatis.ognl.OgnlOps.isEqual(OgnlOps.java:143)
at org.apache.ibatis.ognl.OgnlOps.equal(OgnlOps.java:802)
at org.apache.ibatis.ognl.ASTEq.getValueBody(ASTEq.java:52)
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:470)
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:434)
at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:44)
at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34)
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33)
at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:35)
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33)
at org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply(TrimSqlNode.java:55)
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33)
at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:41)
at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:292)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at com.shengpay.hpsplus.db.interceptor.SlowSqlInterceptor.intercept(SlowSqlInterceptor.java:47)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy185.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
... 45 more
将mybatis的日志级别调整为debug仍然没有看到sql打印,因此排除sql异常,可能是sql预处理报错了。
<logger name="org.apache.ibatis">
<level value="debug" />
</logger>
仔细排查异常,原来是如下地方有问题:
<if test="dataType == 'F'">
and INSERT_TIME > sysdate - 1
</if>
错误分析:
1、test=“datatype == ‘F’ ” 使用的OGNL表达式,而datatype的类型定义如下:
<result column="DATA_TYPE" jdbcType="CHAR" property="dataType" />
该地方想表达的含义是:如果datatype == 字符'F'的条件成立
但是呢,DB中字段的定义是char,可是,在我们使用(test=“datatype == ‘F’ ”)这个ognl表达式做判断的时候,使用的是datatype,而datatype是如何定义的呢?
private String dataType;
问题找到了:
(test=“datatype == ‘F’ ”) 这个表达式,使用了datatype 这个字符串和'F'这个字符做比较,字符和字符串比较,mybatis会做数据类型的统一转换,好了出问题了!!!
解决方案,吧'F'当做字符串对待,用双引号标示:"F"
<if test='dataType == "F"'>
and INSERT_TIME > sysdate - 1
</if>
搞定!!!
Mybatis异常:java.lang.NumberFormatException: For input string: "S"的更多相关文章
- Swagger2异常 java.lang.NumberFormatException: For input string: ""
问题在访问swagger首页时报错: java.lang.NumberFormatException: For input string: "" at java.lang.Numb ...
- mybatis 报错:Caused by: java.lang.NumberFormatException: For input string
mybatis的if标签之前总是使用是否为空,今天要用到字符串比较的时候遇到了困难,倒腾半天,才在一个论坛上找到解决方法.笔记一下,如下: 转自:https://code.google.com/p/m ...
- MyBatis报错:Caused by: java.lang.NumberFormatException: For input string: "XX"
<select id="sltTreatment" resultType="com.vitaminmd.sunny.core.bo.Treatment"& ...
- 解决测试redis集群时报"java.lang.NumberFormatException: For input string: "7003@17003..7002@17002"等异常
一.前言 关于redis5.0的集群模式下,通过客户端测试代码调试报"Exception in thread "main" java.lang.NumberFormatE ...
- java.lang.NumberFormatException: For input string: "title"异常
java.lang.NumberFormatException: For input string: "title" at java.lang.NumberFormatExcept ...
- java.lang.NumberFormatException: For input string: "Y"
nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. ...
- java.lang.NumberFormatException: For input string: "${jdbc.maxActive}"
一.问题 使用SpringMVC和MyBatis整合,将jdbc配置隔离出来的时候出现下面的错误,百度了很久没有找到解决方法,回家谷歌下,就找到解决方法了,不得不说谷歌就是强大,不废话,下面是具体的错 ...
- Cause: java.lang.NumberFormatException: For input string: "D"
异常:Cause: java.lang.NumberFormatException: For input string: "D" 问题回显: 原因分析:'D'只有1位,被认为是ch ...
- 解决java.lang.NumberFormatException: For input string: "id"
今天,项目突然报"java.lang.NumberFormatException:For input string:"id"",项目框架是spring,spri ...
随机推荐
- vue 组件之间数据传递(七)
1.props:父组件 -->传值到子组件 app.vue是父组件 ,其它组件是子组件,把父组件值传递给子组件需要使用 =>props 在父组件(App.vue)定义一个属性(变量)sex ...
- line-height 150%和1.5的区别
好惨啊,九点多了没事做还不能下班,坑爹的测试啊~~~ 刚才拿这个问题调戏了下部门一位资深前端开发,结果发现,他居然不会,呵呵~~~ 这里就说下吧 html: <div class="p ...
- bootstrap-datepicker控件中文 ,只显示年和只显示月份
插件下载地址 https://github.com/uxsolutions/bootstrap-datepicker html <link href="css/bootstrap-da ...
- Windows Server 2012 R2
Windows Server 2012 R2 历史上的Server有2003 server, 2008 server, 2012 server windows server 2012 r2对计算机的消 ...
- [转]Linq语法二
本文将讲述LINQ的基础查询(此文所有例子都使用LINQ to Object) 在此之前,我们先创建一个用于示例的数据源: Student类:表示学生,包括学号.姓名及班级 Courses类:表示学生 ...
- jQuery中表单的常用操作(全选、反选)
表单的全选.反选操作一 <form method="post" action=""> 你爱好的运动是?<input type="ch ...
- ArcGisJS的layers-add-result事件总结
map.on("layers-add-result", initEditing);当地图控件中的所有图层加载完毕之后触发. 注意图层加载完成后返回的的结果:event. funct ...
- http头部如何对缓存的控制
文章自于我的个人博客 使用缓存的目的就是在于减少计算,IO,网络等时间,可以快速的返回,特别是流量比较大的时候,可以节约很多服务器带宽和压力. 一个请求从缓存的方面来说,有三个过程. 本地检查缓存是否 ...
- mysql的三种索引
MySQL中的索引分为3种: 1,主键索引:即用主键当唯一索引 2,常规索引:实现方式为B树和哈希表 3,全文索引:实现原理类似倒排索引,常用来查询字段中包含关键字 下面复习下B-TREE和hash- ...
- 安装office提示Office 16 Click-to-Run Extensibility Component
今天安装office时,提示Office 16 Click-to-Run Extensibility Component或者Office 15 Click-to-Run Extensibility C ...