我被指派去解决别人应用程序中的一个事件。
但是,该应用程序使用 iBATIS 的 sqlMap 和存储过程,而我以前从未使用过此操作。
这是我到目前为止所拥有的:
public void createItemInDb() {
try {
System.out.println("status: " + this.getStatus());
System.out.println("weight: " + this.getWeight());
System.out.println("node name: " + this.getNodeName());
System.out.println("node ui: " + this.getNodeUi());
SqlMapClient sqlMap = AppSqlMapClient.getSqlMapInstance();
sqlMap.queryForObject("createItem", this);
} catch (SQLException e) {
e.printStackTrace();
}
}
//xml文件中的sqlMap
<parameterMap class="item" id="createItemMap">
<parameter property="nodeName" jdbcType="VARCHAR" mode="IN" />
<parameter property="status" jdbcType="INTEGER" mode="IN" />
<parameter property="weight" jdbcType="INTEGER" mode="IN" />
<parameter property="nodeUi" jdbcType="INTEGER" mode="INOUT" />
</parameterMap>
<procedure id="createItem" parameterMap="createItemMap">
{call CREATEITEM (?,?,?,?)}
</procedure>
我遇到了这个异常:
--- The error occurred while executing query procedure.
--- Check the {call CREATEITEM (?,?,?,?)}.
--- Check the SQL Statement (preparation failed).
--- Cause: java.sql.SQLException: [SQL0204] CREATEITEM in *N type *N not found.
Caused by: java.sql.SQLException: [SQL0204] CREATEITEM in *N type *N not found.
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:565)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:540)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:84)
我什至不明白这部分的含义:
未找到 *N 类型 *N 中的 CREATEITEM。
*N 代表什么?
在哪里可以找到存储过程?在其他地方的应用程序文件中找不到 CREATEITEM?
谢谢
最佳答案
存储过程在数据库中,需要用数据库客户端连接数据库,查看存储过程的代码(可能是PL/SQL代码)。
错误“未找到 *N 类型 *N 中的 CREATEITEM。”可能是存储过程的返回类型引起的。您确定它是一个整数吗?
关于java - 调用存储过程 iBATIS 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36552300/