ibatis与存储过程的问题

fy_kenny 2008-04-02 10:51:52
异常概述:The CallableStatement.registerOutParameter(int, int, String method is not implemented.

详细异常信息:
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in cn/com/sigmasoft/test/persistence/sqlmap/procedure_SqlMap.xml.
--- The error occurred while executing query procedure.
--- Check the { call max_in_example(?, ?, ?) }.
--- Check the output parameters (register output parameters failed).
--- Cause: java.sql.SQLException: The CallableStatement.registerOutParameter(int, int, String method is not implemented.
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:566)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:83)
at cn.com.sigmasoft.test.persistence.dao.ProcedureDAOImpl.getMax_in_example(ProcedureDAOImpl.java:59)
at cn.com.sigmasoft.test.test.ProcedureTest.test(ProcedureTest.java:41)
at cn.com.sigmasoft.test.test.ProcedureTest.main(ProcedureTest.java:35)
Caused by: java.sql.SQLException: The CallableStatement.registerOutParameter(int, int, String method is not implemented.
at net.sourceforge.jtds.jdbc.JtdsStatement.notImplemented(JtdsStatement.java:281)
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.registerOutParameter(JtdsCallableStatement.java:316)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.registerOutputParameters(SqlExecutor.java:422)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:275)
at com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
... 8 more
...全文
1288 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
C736059314 2011-06-29
  • 打赏
  • 举报
回复
这个问题我也遇到过啊,大概是因为你的类型没有完全匹配,注意检查一下你的xml文件...
fy_kenny 2008-04-06
  • 打赏
  • 举报
回复
我向专家提问,都没来放的P阿!?

哈哈,
miaoliujun 2008-04-03
  • 打赏
  • 举报
回复
不能
fy_kenny 2008-04-02
  • 打赏
  • 举报
回复
怎么自己发表的 不能修改?!!!!
fy_kenny 2008-04-02
  • 打赏
  • 举报
回复
dao实现的类:

package cn.com.sigmasoft.test.persistence.dao;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.ibatis.common.resources.Resources;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class ProcedureDAOImpl implements ProcedureDAO {

/**
* This method was generated by Abator for iBATIS.
* This method corresponds to the database table userinfo
*
* @abatorgenerated Mon Mar 31 11:41:57 CST 2008
*/
public ProcedureDAOImpl() {
}
/**
* SqlMapClient instances are thread safe, so you only need one.
* In this case, we'll use a static singleton. So sue me. ;-)
*/
private static SqlMapClient sqlMapper;

/**
* It's not a good idea to put code that can fail in a class initializer,
* but for sake of argument, here's how you configure an SQL Map.
*/
static {
try {
Reader reader = Resources.getResourceAsReader("cn/com/sigmasoft/test/persistence/sqlmap/SqlMapConfig.xml");
sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
// Fail fast.
throw new RuntimeException("Something bad happened while building the SqlMapClient instance." + e, e);
}
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#getMax_in_example() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer getMax_in_example() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));

Integer val =
(Integer)sqlMapper.queryForObject("in_example", m);

return val;
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#swap() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer swap() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val =
(Integer) sqlMapper.queryForObject("swapProcedure", m);

return val;
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#maximum() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer maximum() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val = (Integer)sqlMapper.queryForObject("maxOutProcedure", m);

return val;
}
}
fy_kenny 2008-04-02
  • 打赏
  • 举报
回复
sqlMap

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="procedure">
<parameterMap id="pm_in_example" class="java.util.Map">
<parameter property="a" typeName="INTEGER" javaType="int"
jdbcType="NUMERIC" />
<parameter property="b" typeName="INTEGER" javaType="int"
jdbcType="NUMERIC" />
</parameterMap>
<!--
<resultMap id="rm_in_example" class="java.lang.Integer">
<result property="c" javaType="int" jdbcType="INTEGER"/>
</resultMap>
-->
<procedure id="in_example" parameterMap="pm_in_example"
resultClass="int">
{ ?=call max_in_example(?, ?) }
</procedure>

<parameterMap id="swapProcedureMap" class="java.util.Map">
<parameter property="a" mode="INOUT" />
<parameter property="b" mode="INOUT" />
</parameterMap>
<procedure id="swapProcedure" parameterMap="swapProcedureMap">
{ call swap(?, ?) }
</procedure>

<parameterMap id="maxOutProcedureMap" class="java.util.Map">
<parameter property="a" mode="IN" />
<parameter property="b" mode="IN" />
<parameter property="c" mode="OUT" />
</parameterMap>
<procedure id="maxOutProcedure" parameterMap="maxOutProcedureMap">
{ call maximum (?, ?, ?) }
</procedure>
</sqlMap>


[CODE=JAVA]package cn.com.sigmasoft.test.persistence.dao;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.ibatis.common.resources.Resources;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class ProcedureDAOImpl implements ProcedureDAO {

/**
* This method was generated by Abator for iBATIS.
* This method corresponds to the database table userinfo
*
* @abatorgenerated Mon Mar 31 11:41:57 CST 2008
*/
public ProcedureDAOImpl() {
}
/**
* SqlMapClient instances are thread safe, so you only need one.
* In this case, we'll use a static singleton. So sue me. ;-)
*/
private static SqlMapClient sqlMapper;

/**
* It's not a good idea to put code that can fail in a class initializer,
* but for sake of argument, here's how you configure an SQL Map.
*/
static {
try {
Reader reader = Resources.getResourceAsReader("cn/com/sigmasoft/test/persistence/sqlmap/SqlMapConfig.xml");
sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
// Fail fast.
throw new RuntimeException("Something bad happened while building the SqlMapClient instance." + e, e);
}
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#getMax_in_example() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer getMax_in_example() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));

Integer val =
(Integer)sqlMapper.queryForObject("in_example", m);

return val;
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#swap() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer swap() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val =
(Integer) sqlMapper.queryForObject("swapProcedure", m);

return val;
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#maximum() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer maximum() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val = (Integer)sqlMapper.queryForObject("maxOutProcedure", m);

return val;
}
}[/CODE]
fy_kenny 2008-04-02
  • 打赏
  • 举报
回复
sqlMap

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="procedure">
<parameterMap id="pm_in_example" class="java.util.Map">
<parameter property="a" typeName="INTEGER" javaType="int"
jdbcType="NUMERIC" />
<parameter property="b" typeName="INTEGER" javaType="int"
jdbcType="NUMERIC" />
</parameterMap>
<!--
<resultMap id="rm_in_example" class="java.lang.Integer">
<result property="c" javaType="int" jdbcType="INTEGER"/>
</resultMap>
-->
<procedure id="in_example" parameterMap="pm_in_example"
resultClass="int">
{ ?=call max_in_example(?, ?) }
</procedure>

<parameterMap id="swapProcedureMap" class="java.util.Map">
<parameter property="a" mode="INOUT" />
<parameter property="b" mode="INOUT" />
</parameterMap>
<procedure id="swapProcedure" parameterMap="swapProcedureMap">
{ call swap(?, ?) }
</procedure>

<parameterMap id="maxOutProcedureMap" class="java.util.Map">
<parameter property="a" mode="IN" />
<parameter property="b" mode="IN" />
<parameter property="c" mode="OUT" />
</parameterMap>
<procedure id="maxOutProcedure" parameterMap="maxOutProcedureMap">
{ call maximum (?, ?, ?) }
</procedure>
</sqlMap>


[CODE=JAVA]package cn.com.sigmasoft.test.persistence.dao;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.ibatis.common.resources.Resources;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class ProcedureDAOImpl implements ProcedureDAO {

/**
* This method was generated by Abator for iBATIS.
* This method corresponds to the database table userinfo
*
* @abatorgenerated Mon Mar 31 11:41:57 CST 2008
*/
public ProcedureDAOImpl() {
}
/**
* SqlMapClient instances are thread safe, so you only need one.
* In this case, we'll use a static singleton. So sue me. ;-)
*/
private static SqlMapClient sqlMapper;

/**
* It's not a good idea to put code that can fail in a class initializer,
* but for sake of argument, here's how you configure an SQL Map.
*/
static {
try {
Reader reader = Resources.getResourceAsReader("cn/com/sigmasoft/test/persistence/sqlmap/SqlMapConfig.xml");
sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
reader.close();
} catch (IOException e) {
// Fail fast.
throw new RuntimeException("Something bad happened while building the SqlMapClient instance." + e, e);
}
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#getMax_in_example() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer getMax_in_example() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));

Integer val =
(Integer)sqlMapper.queryForObject("in_example", m);

return val;
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#swap() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer swap() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val =
(Integer) sqlMapper.queryForObject("swapProcedure", m);

return val;
}

/*
* Override method @see cn.com.sigmasoft.test.persistence.dao.ProcedureDAO#maximum() of the class ProcedureDAOImpl.java
*
* @return
* @throws SQLException
*/
public Integer maximum() throws SQLException {
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val = (Integer)sqlMapper.queryForObject("maxOutProcedure", m);

return val;
}
}[/CODE]
miaoliujun 2008-04-02
  • 打赏
  • 举报
回复
感觉是你的参数类型或个数有问题,不匹配
fy_kenny 2008-04-02
  • 打赏
  • 举报
回复
我查看了些资料。但是,都没有很多的解决方案。

还请大家知道的,多多发表交流一下技术阿。谢了
livan1038 2008-04-02
  • 打赏
  • 举报
回复
喔喔,占一個位置,學習學習

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧