开发者社区> 技术小阿哥> 正文

mybatis插入数据库时的问题记录

简介:
+关注继续查看

mybatis接口调用如下

1
rowPropSubInfoMapper.insertRowPropSubInfo(iRowPropSubInfoModel);


使用的mapper配置如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<insert id="insertRowPropSubInfo"
        parameterType="com.sinosig.evaluation.fcff.model.dto.IRowPropSubInfoModel">
        insert into
        t_eva_fcff_row_property
        (FCFFID,
        ROWCODE,
        ROWNAME,
        ROWDESCRIPTION,
        ISSHOW,
        CURRENTPREMETHOD,
        CURRENTPREVALUE,
        CURRENTSCALEBASE,
        WARNINGDESCRIPTION)
        values
        (#{fcffid},
        #{code},
        #{name},
        #{description},
        #{isshow},
        #{currentPremethodCode},
        #{currentPreValue},
        #{currentScaleBase},
        #{warningDescription})
    </insert>


抛出的异常信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
[DEBUG]2013-12-17 17:26:54,166 java.sql.Connection#debug()@47: ==>  Preparing: insert into t_eva_fcff_row_property (FCFFID, ROWCODE, ROWNAME, ROWDESCRIPTION, ISSHOW, CURRENTPREMETHOD, CURRENTPREVALUE, CURRENTSCALEBASE, WARNINGDESCRIPTION) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
[DEBUG]2013-12-17 17:26:54,166 org.mybatis.spring.SqlSessionUtils#debug()@47: Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2a851f]
[DEBUG]2013-12-17 17:26:54,166 org.springframework.jdbc.datasource.DataSourceUtils#doReleaseConnection()@327: Returning JDBC Connection to DataSource
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: java.lang.ArrayIndexOutOfBoundsException: 9
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)
    at $Proxy5.insert(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:236)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:79)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
    at $Proxy32.insertRowPropSubInfo(Unknown Source)
    at com.sinosig.evaluation.fcff.service.manage.impl.RowPropSubInfoTempSaveImpl.visitRowPropSubInfo(RowPropSubInfoTempSaveImpl.java:111)
    at com.sinosig.evaluation.fcff.model.impl.FcffModelImpl.acceptVisitor(FcffModelImpl.java:1203)
    at com.sinosig.evaluation.fcff.service.manage.impl.RowPropSubInfoTempSaveImpl.updateSubInfo(RowPropSubInfoTempSaveImpl.java:77)
    at com.sinosig.evaluation.fcff.service.manage.AbstractSaveSubInfoService.call(AbstractSaveSubInfoService.java:95)
    at test.com.sinosig.evaluation.fcff.service.RowSubInfoSaveImplTest.testUpdateSubInfo(RowSubInfoSaveImplTest.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing statement.  Cause: java.lang.ArrayIndexOutOfBoundsException: 9
    at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:91)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:54)
    at org.apache.ibatis.executor.ReuseExecutor.prepareStatement(ReuseExecutor.java:73)
    at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:46)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
    ... 33 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 9
    at oracle.jdbc.driver.OracleSql.computeBasicInfo(OracleSql.java:950)
    at oracle.jdbc.driver.OracleSql.getSqlKind(OracleSql.java:623)
    at oracle.jdbc.driver.OraclePreparedStatement.<init>(OraclePreparedStatement.java:1212)
    at oracle.jdbc.driver.T4CPreparedStatement.<init>(T4CPreparedStatement.java:28)
    at oracle.jdbc.driver.T4CDriverExtension.allocatePreparedStatement(T4CDriverExtension.java:68)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3140)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3042)
    at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:5890)
    at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:508)
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:400)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:53)
    at $Proxy33.prepareStatement(Unknown Source)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:65)
    at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:82)
    ... 45 more


尤其奇怪的是,如果在insert语句中,将插入的列减少到7列或以下,则能够正常执行;8列或以上就会抛出这个异常,并且java.lang.ArrayIndexOutOfBoundsException: 9最后的数字就是列数。


折磨了我整整三天了。如果算上以前的问题,至少折磨了我一个礼拜了。头大。




本文转自 斯然在天边 51CTO博客,原文链接:http://blog.51cto.com/winters1224/1341638,如需转载请自行联系原作者

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Spring Boot2.x-09 基于Spring Boot 2.1.2 + Mybatis使用自定义注解实现数据库切换
Spring Boot2.x-09 基于Spring Boot 2.1.2 + Mybatis使用自定义注解实现数据库切换
13 0
【Spring】使用 MyBatis 操作数据库
1. MyBatis 是什么 2. 为什么要使用 MyBatis 3. MyBatis 框架交互流程 4. 配合 Spring 来使用 MyBatis 4.1 添加 MyBatis 框架支持 4.2 配置数据库 4.3 添加实体类 4.4 添加 mapper 接口 4.5 通过注解的方式操作数据库 4.5.1 增加用户 4.5.2 删除用户 4.5.3 修改用户数据 4.5.4 查询用户数据 4.6 通过 XML 文件的形式操作数据库 4.6.1 配置 XML 文件 4.6.2 在 yml 中配置 xml 路径 4.6.3 查询用户数据 4.6.4 批量查询用户数据 4.6.5 批量插入用户数
31 0
【SSM】MyBatis 操作数据库(重点:Mybatis两种使用方式)
本文重点介绍ORM 框架和Mybatis的关系、如何通过注解 或者 通过XML配置文件的使用Mybatis,以及参数占位符 #{} 和 ${} 的区别, 什么是sql 注入。
47 0
Mybatis 批量将list数据插入到数据库竟然这样处理
Mybatis 批量将list数据插入到数据库竟然这样处理
66 0
mybatis 快速生成Java POJO文件及数据库Mapper文件【文末彩蛋】
mybatis 快速生成Java POJO文件及数据库Mapper文件【文末彩蛋】
57 0
spring-boot-route(八)整合mybatis操作数据库
MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Ordinary Java Object,普通的 Java对象)映射成数据库中的记录。
55 0
数据库树状结构的设计和处理以及Spring Boot中MyBatis对树状结构的级联操作
数据库树状结构的设计和处理以及Spring Boot中MyBatis对树状结构的级联操作
107 0
玩“公主焊接”,顺便学习学习数据库关系映射与Spring Boot中MyBatis(SSM框架)的级联操作(bushi)
玩“公主焊接”,顺便学习学习数据库关系映射与Spring Boot中MyBatis(SSM框架)的级联操作(bushi)
195 0
MyBatis插入100w数据使用编程式事务造成数据库被锁原因
MyBatis插入100w数据使用编程式事务造成数据库被锁原因
75 0
MyBatis中多数据库支持---待续
MyBatis中多数据库支持---待续
79 0
+关注
技术小阿哥
文章
问答
视频
文章排行榜
最热
最新
相关电子书
更多
Java Spring Boot开发实战系列课程【第6讲】:Spring Boot 2.0实战MyBatis与优化(Java面试题)
立即下载
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
相关实验场景
更多