添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
拉风的电池  ·  Common Problems - ...·  5 月前    · 
严肃的西装  ·  ion-checkbox: Ionic ...·  8 月前    · 
豪爽的啄木鸟  ·  Docker Compose | Sutune·  8 月前    · 
细心的机器猫  ·  劳召欣·  1 年前    · 
我用ibatis调sybase的存储过程 出错了,代码如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
  PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
  "http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Student">
	<procedure id="select_student" resultClass="com.qh.pojo.Student">
		{call test_proc1}
	</procedure>
</sqlMap>


package com.qh.test;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.qh.commons.DBUtil;
import com.qh.pojo.Student;
public class Test1 {
	public static void main(String[] args) {
		SqlMapClient sqlMap = DBUtil.getSqlMapClient();
		List<Student> list = null;
		try {
			sqlMap.startTransaction();
			list = sqlMap.queryForList("Student.select_student");
			sqlMap.commitTransaction();
			for(Student stu:list) {
				System.out.println(stu.getId()+"\t"+stu.getName()+"\t"+
						stu.getSex()+"\t"+stu.getBirthday()+"\t"+stu.getClassname());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();


create proc test_proc1 as  
begin 
	select id,name,sex,birthday,classname from student order by id 
end


报错如下:
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/qh/pojo/xml/Student.xml.  
--- The error occurred while applying a parameter map.  
--- Check the Student.select_student-InlineParameterMap.  
--- Check the statement (update procedure failed).  
--- Cause: com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure 'test_proc1' may be run only in unchained transaction mode. The 'SET CHAINED OFF' command will cause the current session to use unchained transaction mode.
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:201)
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:122)
	at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:98)
	at com.qh.test.Test1.main(Test1.java:19)
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure 'test_proc1' may be run only in unchained transaction mode. The 'SET CHAINED OFF' command will cause the current session to use unchained transaction mode.
	at com.sybase.jdbc3.tds.Tds.processEed(Tds.java:2942)
	at com.sybase.jdbc3.tds.Tds.nextResult(Tds.java:2246)
	at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
	at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:220)
	at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:203)
	at com.sybase.jdbc3.jdbc.SybStatement.executeLoop(SybStatement.java:1868)
	at com.sybase.jdbc3.jdbc.SybCallableStatement.execute(SybCallableStatement.java:157)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:62)
	at $Proxy1.execute(Unknown Source)
	at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:278)
	at com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:39)
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
	... 7 more

我查了很久也没查出问题在哪,请各位帮忙一下,感谢不尽 问题补充:
dmewy 写道
你的procedure没有返回值.


哪个具体怎么写呢?