2 xiesq5112 xiesq5112 于 2015.07.03 16:08 提问

ibatis Oracle函数配置(字符串格式不匹配)

用iBATIS配置数据库函数调用的问题,出现的是ORA-01861: literal does not match format string(字符串格式不匹配)
求大虾 解救 急

下面是关键代码

这是数据库函数的参数列表
(pi_Money IN NUMBER, --交易金额
pi_BankNo IN VARCHAR2, -- 银行代码
pi_FundId IN VARCHAR2, -- 目标基金
pi_Apkind IN VARCHAR2, --购买方式

pi_CustNo IN VARCHAR2, -- 交易账号
pi_Apdt IN DATE, -- 申请日期

po_fee OUT NUMBER, -- 手续费
po_ErrCode OUT VARCHAR2, -- 返回代码
po_ErrMsg OUT VARCHAR2 -- 返回信息

ibatis的配置

<![CDATA[
{#{flag,mode=OUT,jdbcType=INTEGER}=call f_GetInternetFee(#{pi_Money,mode=IN,jdbcType=DOUBLE},
#{pi_BankNo,mode=IN,jdbcType=VARCHAR},
#{pi_FundId,mode=IN,jdbcType=VARCHAR},
#{pi_Apkind,mode=IN,jdbcType=VARCHAR},
#{pi_CustNo,mode=IN,jdbcType=VARCHAR},
to_date('2014/11/11','yyyy-MM-dd'),

            #{po_fee,mode=OUT,jdbcType=DOUBLE},
            #{po_ErrCode,mode=OUT,jdbcType=VARCHAR},
            #{po_ErrMsg,mode=OUT,jdbcType=VARCHAR})} 
    ]]> 
</select>

这是测试代码
Map<String,Object> map=new HashMap<String, Object>();
        map.put("pi_Money", 50000.0);
        map.put("pi_BankNo", "095");
        map.put("pi_FundId", "050002");

        map.put("pi_Apkind", "022");
        map.put("pi_CustNo", "001553218");
        map.put("pi_Apdt", new Date());
        internetFeeCenterDao.getInternetFee(map);
        System.out.println(map.get("po_fee"));

        报错的结果:
        2015-07-03 15:58:05 [java.sql.PreparedStatement]-[DEBUG] ==>  Executing: {?=call f_GetInternetFee (?, ?, ?, ?, ?, ?, ?, ?, ? )}  -(:28)

2015-07-03 15:58:05 [java.sql.PreparedStatement]-[DEBUG] ==> Parameters: 50000.0(Double), 095(String), 050002(String), 022(String), 001553218(String), 2015-01-11(String) -(:28)
org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: java.sql.SQLException: ORA-01861: literal does not match format string

ORA-06512: at line 1

The error may involve com.bosera.trade.dao.center.IInternetFeeCenterDao.getInternetFee-Inline

The error occurred while setting parameters

Cause: java.sql.SQLException: ORA-01861: literal does not match format string

ORA-06512: at line 1

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:80)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38)
at $Proxy10.getInternetFee(Unknown Source)
at com.bosera.trade.junittest.JunitMybatisTest.test(JunitMybatisTest.java:62)
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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
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: java.sql.SQLException: ORA-01861: literal does not match format string
ORA-06512: at line 1

2个回答

strutce
strutce   Ds   Rxr 2015.07.03 16:26

参数如期为字符串,与字段类型不符,你不作to_date处理应该是没有问题的

xiesq5112
xiesq5112   2015.07.03 17:21

我测试了好几个小时,后来发现错误提示里还是以前的数据。我就重启了MyEclipse,测试发现是DATE格式错误!自己解决了!

Csdn user default icon
上传中...
上传图片
插入图片