EXCEPTION-IBATIS
CreateTime--2016年8月23日08:44:03
Author:Marydon
ibatis的sqlMap的xml文件配置出现的异常信息及解决方案
声明:异常类文章主要是记录了我遇到的异常信息及解决方案,解决方案大部分都是百度解决的,(这里只是针对我遇到的做个汇总),特此声明!
异常一
Cause: java.sql.SQLException: Invalid parameter object type. Expected 'com.entity.User' but found 'java.util.HashMap'.
ibatis配置问题
<parameterMap class="User" id="userMap">
<parameter property="userId"/>
<parameter property="userName"/>
<parameter property="userPass"/>
<parameter property="sex"/>
</parameterMap>
解决方案:
将class的值改为java.util.Map
Map对象的键必须和数据库中表的字段名保持一致,否则报错;
注意:
ibatis/mybatis可以自动将Map对象的键值与数据库中列名与该列的值对应起来
异常二
Caused by: java.sql.SQLException: ORA-00933: SQL 命令未正确结束
异常三
There is no READABLE property named 'userId' in class 'java.lang.String'
<!--
动态查询,查询所有的用户信息;根据id查询用户信息;根据姓名进行模糊查询 三合一
-->
当查询姓名时,出现异常;原因:只运行userId的sql语句,无法进入userName
ibatis配置问题
<select id="getUser" resultClass="User">
select * from user2
<dynamic prepend="where">
<isNotEmpty prepend="and" property="value">
userId=#value#
</isNotEmpty>
<isNotEmpty prepend="and" property="value">
userName like '%$value$%'
</isNotEmpty>
</dynamic>
</select>
解决方案:
1. 传参使用Map对象,将userId和userName封装到Map对象中再将Map传进去(虽然只传其中一个参数,也必须如此);
2.配置Map对象与实体类的映射关系;
3.指定传入参数类型: parameterMap="userMap"
<select id="getUser" resultClass="User" parameterMap="userMap">
select * from user2
<dynamic prepend="where">
<isNotEmpty prepend="and" property="value">
userId=#value#
</isNotEmpty>
<isNotEmpty prepend="and" property="value">
userName like '%$value$%'
</isNotEmpty>
</dynamic>
</select>
异常四
元素类型为 "sqlMapConfig" 的内容必须匹配 "(properties?,settings?,resultObjectFactory?,typeAlias*,typeHandler*,transactionManager?,sqlMap+)+"。顺序错误
在ibatis的SqlMapConfig.xml文件中使用指定标签的顺序必须按照上面的顺序进行
解决方案:
在本次中,我将setting标签放到了transactionManager标签的后面;它必须放在properties标签的后面
students-classes3.0项目异常
异常五
java.lang.Long cannot be cast to java.lang.Integer
详细信息
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
at com.xyhsoft.demo.service.dao.clazz.impl.ClazzDaoImpl.insertClazz(ClazzDaoImpl.java:35)
at com.xyhsoft.demo.service.bo.clazz.impl.ClazzBoImpl.insertClazz(ClazzBoImpl.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
序列配置问题
<selectKey keyProperty="CLAZZID" resultClass="long">
SELECT SEQ_CLAZZ3.NEXTVAL as CLAZZID FROM DUAL
</selectKey>
解决方案:
将long改为int
异常六
The error occurred in com/xyhsoft/demo/conf/ibatis/oracle/clazzConfig.xml.
--- The error occurred while applying a result map.
--- Check the com.xyhsoft.demo.clazz.getClazzById-AutoResultMap.
--- Check the result mapping for the 'CLAZZNAME' property.
--- Cause: java.lang.RuntimeException: JavaBeansDataExchange could not instantiate result class. Cause: java.lang.InstantiationException: java.util.Map; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/xyhsoft/demo/conf/ibatis/oracle/clazzConfig.xml.
--- The error occurred while applying a result map.
--- Check the com.xyhsoft.demo.clazz.getClazzById-AutoResultMap.
--- Check the result mapping for the 'CLAZZNAME' property.
--- Cause: java.lang.RuntimeException: JavaBeansDataExchange could not instantiate result class. Cause: java.lang.InstantiationException: java.util.Map
Map集合问题
<select id="getClazzById" parameterClass="map" resultClass="map">
select * from clazz3 where CLAZZID=#CLAZZID#
</select>
解决方案:
当map作为返回类型时,必须是hashmap;返回类型将resultClass="map"改为resultClass="hashmap"
CopyTime--2017年1月7日17:40:04
异常七
Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.
原因:
ibatis XML 文档结构必须从头至尾包含在同一个实体内。
解决方案:
方案一:
查看是否有标签没有闭合
方案二:必须是标准的注释(遇到的情况)
xml文件中的中文注释两边是否无空格,如没有,则加上空格
左右边界加上空格的方式解决 <!-- 中文注解 -->是对的
方案三:
也可能是配置文件sqlMapConfig.xml或映射文件中http://www.ibatis.com/dtd/sql-map-config-2.dtd"> 含有多个空格的原因
异常八
连接数据库报错
java.sql.SQLException: The Network Adapter could not establish the connection
解决方案
方案一:
数据库服务未开启
方案二:
配置不正确
方案三:
192.1**.此域名只有在连接局域网时使用,断网情况下用localhost
说明:数据库连接url--jdbc:oracle:thin:@localhost:1521/orcl,/orcl或:orcl或/ORCL或:ORCL都可以
异常九
Cause: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'id' in class 'com.entity.User'
The Network Adapter could not establish the connection
Cause: java.sql.SQLException: ORA-00957: 重复的列名
update user2 set userName=#userName#,userName=#userName#,sex=#sex#,status=#status# where userId=#userId#
UpdateTime--2017年2月20日18:49:30
demoGyyunPlatform项目
异常十
com.ibatis.sqlmap.client.SqlMapException: There is no statement named gongYiPlatForm.dataSynchronization in this SqlMap.
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.getMappedStatement(SqlMapExecutorDelegate.java:232)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:449)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
at org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:383)
at org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:381)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)
at org.springframework.orm.ibatis.SqlMapClientTemplate.update(SqlMapClientTemplate.java:381)
at com.xyhsoft.demo.service.dao.gongyi.impl.DaoGongYiImpl.transferProcedure(DaoGongYiImpl.java:26)
at com.xyhsoft.demo.service.bo.gongyi.impl.BoGongYiImpl.transferProcedure(BoGongYiImpl.java:32)
原因:
iBATIS有两个配置文件:ibatisConfig.xml和sqlmap-oracle-config.xml,ibatisConfig.xml是总配置文件,sqlmap-oracle-config.xml是子配置文件,总配置文件引入了子配置文件
解决方案:
ibatis的配置文件只能有一个(<sqlMapConfig></sqlMapConfig>标签只能有一个),其他ibatis文件必须是sqlMap(<sqlMap namespace="base"></sqlMap>)
ibatis的配置文件去引入sqlMap文件
EXCEPTION-IBATIS的更多相关文章
- Exception:HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
主要错误信息如下: HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not ...
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [1, 0, param1, param2]
Spring+mybatis错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bi ...
- Cause: net.sf.cglib.beans.BulkBeanException; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
2017-03-13 15:40:15,003 ERROR [com.hisense.hitv.service.dotexc.impl.DotExcPolicyServiceImpl.updateD ...
- 解决:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'requestMap.maintenancename != null and requestMap.maintenance
异常如下:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.Builde ...
- 怪事年年有,今天特别多!org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'empno' not found. Available parameters are [emp, deptno, param1, param
错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Binding ...
- SpringBoot报错:nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in com.tuyrk.test.User matching [java.lang.Long, java.lang.String, java.lang.String]
错误提示: Caused by: org.apache.ibatis.executor.ExecutorException: No constructor found in com.tuyrk._16 ...
- MyBatis 传List参数 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'idList' not found.
在MyBatis传入List参数时,MyBatis报错:nested exception is org.apache.ibatis.binding.BindingException: Paramete ...
- Springboot-001-解决nested exception is org.apache.ibatis.binding.BindingException: Parameter 'env' not found. Available parameters are [arg1, arg0, param1, param2]
环境:Springboot + Mybatis + MySQL + VUE 场景: 前端发出数据比对请求,在服务后台与数据库交互时,接口提示错误信息如下所示: { "code": ...
- Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com.test.bean.groupMapper is not known to the MapperRegistry.
Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com. ...
- MyBatis笔记----报错Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@41cf53f9: startup ...
随机推荐
- 使用Enum.TryParse()实现枚举的安全转换
在项目中,有时候会用到领域枚举和DTO枚举的映射和转换.有一个现实的问题是:如果领域枚举项发生变化,而DTO枚举项没有及时更新,这样会造成映射不上的问题.那么,如何避免此类问题呢? 先看领域枚举和DT ...
- DevExpress Components16.2.6 Source Code 编译
DevExpress 是一个比较有名的界面控件套件,提供了一系列优秀的界面控件.这篇文章将展示如何在拥有源代码的情况下,对 DevExpress 的程序集进行重新编译. 特别提示:重编译后,已安装好的 ...
- 安装程序不能验证Update.inf文件的完整性,请确定加密服务正在此计算机上执行
近期安装Microsoft .NET Framework 4(独立安装程序)时,提示"安装程序不能验证Update.inf文件的完整性,请确定加密服务正在此计算机上执行" 没法放狗 ...
- quartz 中JobExecutionContext的使用
假如execute方法中需要一些额外的数据怎么办?比如说execute 中希望发送一封邮件,但是我需要知道邮件的发送者.接收者等信息? 存在两种解决方案: 1.JobDataMap类: 每个Jo ...
- Java-JDBC调用批处理、存储过程、事务
一.使用Batch批量处理数据库 当需要向数据库发送一批SQL语句执行时,应避免向数据库一条条的发送执行,而应采用JDBC的批处理机制,以提升执行效率.; 1.实现批处理有两种方式,第一种方式: S ...
- 把NDK的工具链提取出来单独使用
独立toolchain 把NDK压缩包解压到系统,如/mnt目录下,后在/mnt目录下建立文件夹my_ndk_toolchain,然后再/mnt目录下执行以下命令:/mnt/android-ndk-r ...
- 用java解析在OpenStreetMap上下载的地图数据
采用dom4j解析下载的xml文件,java程序如下: package gao.map.preprocess; import java.io.BufferedWriter; import java.i ...
- JDBC操作数据库的批处理
在JDBC开发中,操作数据库需要与数据库建立连接,然后将要执行的SQL语句传送到数据库服务器,最后关闭数据库连接,都是按照这样一个流程进行操作的.如果按照该流程执行多条SQL语句,那么就需要建立多个数 ...
- Java实现将Excel导入数据库和从数据库中导出为Excel
实现的功能: 用Java实现从Excel导入数据库,如果存在就更新 将数据库中的数据导出为Excel 1.添加jxl.jar mysql-connector-java.1.7-bin.jar包到项目的 ...
- 开启otl的64位长整数支持
要开启OTL的64位长整数支持,必须先定义宏 #define OTL_BIGINT __int64 // VC++, Borland C++ 或者 #define OTL_BIGINT long lo ...