JAVA ibatis 调用oracle存储过程报错,请各位帮忙看看啊,搞了一天了。不过我没分,希望大家慷慨相助。
没有增加输出参数时没问题,加了就一直报错IBATIS配置<parameterMapclass="java.util.Map"id="tableTempl"><parame...
没有增加输出参数时没问题,加了就一直报错
IBATIS配置
<parameterMap class="java.util.Map" id="tableTempl">
<parameter property="p_sc_user_id" jdbcType="number"
javaType="java.lang.String" mode="IN" />
<parameter property="p_sc_class_id" jdbcType="number"
javaType="java.lang.String" mode="IN" />
<parameter property="p_remarks" jdbcType="varchar"
javaType="java.lang.String" mode="IN" />
<parameter property="p_created_by" jdbcType="varchar"
javaType="java.lang.String" mode="IN" />
<parameter property="errorcode" jdbcType="varchar"
javaType="java.lang.String" mode="INOUT" />
</parameterMap>
<!-- 自定一个sqlmap-ID parameterMap指定为上面定义的map(重要)-->
<procedure id="SP_SysClientBaseTempTable" parameterMap="tableTempl">
<!-- <![CDATA[ 语句 ]]> 其中:<![CDATA[ ]]> 最好不要换行-->
<![CDATA[{call insertclass(?,?,?,?,?)}]]>
</procedure>
JAVA类
//调存储过程
public String updateStudent(Student student) {
Map map = new HashMap();
map.put("p_sc_user_id", student.getSc_user_id());
map.put("p_sc_class_id", student.getSc_class_id());
map.put("p_remarks", student.getRemarks());
map.put("p_created_by", student.getCreated_by());
map.put("errorcode","0");
try {
con.getSqlMap().queryForObject("SP_SysClientBaseTempTable",map);
System.out.print(map.get("errorcode").toString());
} catch (SQLException e) {
e.printStackTrace();
return map.get("errorcode").toString();
}
return map.get("errorcode").toString();
}
测试主函数:
public static void main(String[] args) {
Sdao dao=new Sdao();
Student ss = new Student();
ss.setSc_user_id("1");
ss.setSc_class_id("5");
ss.setRemarks("0802");
ss.setCreated_by("xx");
dao.updateStudent(ss);
}
这里是部分错误信息
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/test0507/struts/dx/UserBean.xml.
--- The error occurred while executing query procedure.
--- Check the {call insertclass(?,?,?,?,?)}.
--- Check the output parameters (register output parameters failed).
--- Cause: java.sql.SQLException: 无效的列类型
Caused by: java.sql.SQLException: 无效的列类型
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:93)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:70) 展开
IBATIS配置
<parameterMap class="java.util.Map" id="tableTempl">
<parameter property="p_sc_user_id" jdbcType="number"
javaType="java.lang.String" mode="IN" />
<parameter property="p_sc_class_id" jdbcType="number"
javaType="java.lang.String" mode="IN" />
<parameter property="p_remarks" jdbcType="varchar"
javaType="java.lang.String" mode="IN" />
<parameter property="p_created_by" jdbcType="varchar"
javaType="java.lang.String" mode="IN" />
<parameter property="errorcode" jdbcType="varchar"
javaType="java.lang.String" mode="INOUT" />
</parameterMap>
<!-- 自定一个sqlmap-ID parameterMap指定为上面定义的map(重要)-->
<procedure id="SP_SysClientBaseTempTable" parameterMap="tableTempl">
<!-- <![CDATA[ 语句 ]]> 其中:<![CDATA[ ]]> 最好不要换行-->
<![CDATA[{call insertclass(?,?,?,?,?)}]]>
</procedure>
JAVA类
//调存储过程
public String updateStudent(Student student) {
Map map = new HashMap();
map.put("p_sc_user_id", student.getSc_user_id());
map.put("p_sc_class_id", student.getSc_class_id());
map.put("p_remarks", student.getRemarks());
map.put("p_created_by", student.getCreated_by());
map.put("errorcode","0");
try {
con.getSqlMap().queryForObject("SP_SysClientBaseTempTable",map);
System.out.print(map.get("errorcode").toString());
} catch (SQLException e) {
e.printStackTrace();
return map.get("errorcode").toString();
}
return map.get("errorcode").toString();
}
测试主函数:
public static void main(String[] args) {
Sdao dao=new Sdao();
Student ss = new Student();
ss.setSc_user_id("1");
ss.setSc_class_id("5");
ss.setRemarks("0802");
ss.setCreated_by("xx");
dao.updateStudent(ss);
}
这里是部分错误信息
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/test0507/struts/dx/UserBean.xml.
--- The error occurred while executing query procedure.
--- Check the {call insertclass(?,?,?,?,?)}.
--- Check the output parameters (register output parameters failed).
--- Cause: java.sql.SQLException: 无效的列类型
Caused by: java.sql.SQLException: 无效的列类型
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:93)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:70) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询