iBatis调用Oracle返回游标的存储过程时 jdbcType 怎么设置呢? 我设为oracle.jdbc.OracleTypes.CURSOR 时报错:(设为 OTHER 也不行)
==========================================
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/mydomain/data/Product.xml.
--- The error occurred while executing query procedure.
--- Check the {call viewProduct(?,?)}.
--- Check the output parameters (register output parameters failed).
--- Cause: java.sql.SQLException: 无效的列类型
Caused by: java.sql.SQLException: 无效的列类型
==========================================
配置文件如下:
<parameterMap id="searchParam" class="Map">
<parameter property="productId" jdbcType="INTEGER" javaType="int" mode="IN"/>
<parameter property="rs" jdbcType="oracle.jdbc.OracleTypes.CURSOR" javaType="java.sql.ResultSet" mode="OUT"/>
</parameterMap>
<procedure id="searchProcedure" parameterMap="searchParam">
{call viewProduct(?,?)}
</procedure>
------------------
存储过程如下:
CREATE OR REPLACE PROCEDURE viewproduct(pid IN number, pc out tcursor.p_cursor)
AS
BEGIN
OPEN pc FOR select product_id,name,price,product_type_id from products where product_id = pid;
END viewproduct;
------------------
用Java调用时可以成功:
CallableStatement cs=con.prepareCall("{call viewProduct(?,?)}");
cs.setInt(1,1);
cs.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR); //CURSOR的值是-10
cs.execute();
ResultSet rs = (ResultSet)cs.getObject(2);
使用Java时如果registerOutParameter(2,Types.OTHER) 是不能成功的,OTHER的只是1111,如果我写成registerOutParameter(2,-10) 也是ok的.
==========================================
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/mydomain/data/Product.xml.
--- The error occurred while executing query procedure.
--- Check the {call viewProduct(?,?)}.
--- Check the output parameters (register output parameters failed).
--- Cause: java.sql.SQLException: 无效的列类型
Caused by: java.sql.SQLException: 无效的列类型
==========================================
配置文件如下:
<parameterMap id="searchParam" class="Map">
<parameter property="productId" jdbcType="INTEGER" javaType="int" mode="IN"/>
<parameter property="rs" jdbcType="oracle.jdbc.OracleTypes.CURSOR" javaType="java.sql.ResultSet" mode="OUT"/>
</parameterMap>
<procedure id="searchProcedure" parameterMap="searchParam">
{call viewProduct(?,?)}
</procedure>
------------------
存储过程如下:
CREATE OR REPLACE PROCEDURE viewproduct(pid IN number, pc out tcursor.p_cursor)
AS
BEGIN
OPEN pc FOR select product_id,name,price,product_type_id from products where product_id = pid;
END viewproduct;
------------------
用Java调用时可以成功:
CallableStatement cs=con.prepareCall("{call viewProduct(?,?)}");
cs.setInt(1,1);
cs.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR); //CURSOR的值是-10
cs.execute();
ResultSet rs = (ResultSet)cs.getObject(2);
使用Java时如果registerOutParameter(2,Types.OTHER) 是不能成功的,OTHER的只是1111,如果我写成registerOutParameter(2,-10) 也是ok的.