ORA-06550:PLS-00103:使用mybatis TypeHandler遇到符号“”

时间:2018-04-30 08:52:12

标签: mybatis

我使用TypehandlerList<Dep>映射到oracle数组...这里是处理程序中的setPArameter方法:

    public void setParameter(PreparedStatement ps, int i, List<Dep> parameter, JdbcType jdbcType)
            throws SQLException {
        Connection connection = ps.getConnection();
//      StructDescriptor structDescriptor = StructDescriptor.createDescriptor("MEMS_ARR", connection);
        Struct[] structs = null;
        if(parameter != null && parameter.size() >0) {
            structs = new Struct[parameter.size()];
            for (int index = 0; index < parameter.size(); index++)
            {
                Dep dep = parameter.get(index);
                Object[] params = new Object[7];
                params[0] = dep.getOrder();
                params[1] = dep.getIdTp;
                params[2] = dep.getId();
                params[3] = " ";
                params[4] = " ";
                params[5] = " ";
                params[6] = " ";
    //            STRUCT struct = new STRUCT(structDescriptor, ps.getConnection(), params);
                structs[index] = connection.createStruct("MEMS", params);
            }
    //        ArrayDescriptor desc = ArrayDescriptor.createDescriptor("MEMS_ARR", ps.getConnection());
    //        ARRAY oracleArray = new ARRAY(desc, ps.getConnection(), structs);
        }else {
            parameter = new ArrayList<DependentDTO>();
            structs= new Struct[0];
        }
        this.parameter = parameter;
        Array oracleArray = ((OracleConnection) connection).createOracleArray("MEMS_ARR", structs);
        ps.setArray(i, oracleArray);
    }

这里是MEMS类型:

create or replace TYPE MEMS AS OBJECT 
( MEM1          NUMBER(2,0),
  MEM2          VARCHAR2(1),
  MEM3          VARCHAR2(15),
  MEM4          VARCHAR2(60),
  MEM5          VARCHAR2(1),
  MEM6          VARCHAR2(40),
  MEM7          VARCHAR2(10)
);

,这是使用Typehandler的xml映射文件的一部分:

#{nat,javaType=String,jdbcType=VARCHAR,mode=IN}, --nat
**#{deps,javaType=List,jdbcType=ARRAY,mode=IN,jdbcTypeName=MEMS_ARR,typeHandler=com.my.package.MyHandler}, --mems**
#{res,javaType=String,jdbcType=VARCHAR,mode=OUT} --res

错误日志如下:

Error querying database. Cause: java.sql.SQLException: ORA-06550: line 31, column 5: PLS-00103: Encountered the symbol "" when expecting one of the following: . ( ) , * @ % & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || indicator multiset member submultiset The symbol "(" was substituted for "" to continue. ORA-06550: line 44, column 4: PLS-00103: Encountered the symbol ";" when expecting one of the following: . ( ) , * % & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset ### The error may exist in file [E:\path\to\mapper\ADao.xml] ### The error may involve my.package.ADao.mthodToCall -Inline ### The error occurred while setting parameters ### SQL: {call MY_PROC( ... , --nat?, **--mems? --res**)}

正如您在日志中看到的那样,mems被替换为空字符串或与下一个arg res合并...逗号不存在

另外请注意,我已经在mybatis代码中进行了调试,并意识到调用映射setParameter方法并且输入List正确映射到oracle数组...问题发生在实际调用时

1 个答案:

答案 0 :(得分:0)

问题实际上是我只是错过了前两个参数之间的一个逗号...但错误指向错误的参数来查看