uncategorized SQLException for SQL []; SQL state [ZZZZZ]; error code [7713]; Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.

使用场景
spring2.5.6
hibernate3.3.1GA
Sybase15
jconn3驱动
使用spring的jdbctemplate调用Sybase15的存储过程报错
ERROR: ConnectionCallback; uncategorized SQLException for SQL []; SQL state [ZZZZZ]; error code [7713]; Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.;
nested exception is com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.
org.springframework.jdbc.UncategorizedSQLException: ConnectionCallback; uncategorized SQLException for SQL []; SQL state [ZZZZZ]; error code [7713]; Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.;
nested exception is com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure ‘proc_xxx’ may be run only in unchained transaction mode. The ‘SET CHAINED OFF’ command will cause the current session to use unchained transaction mode.
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:349)
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Stored procedure ‘proc_xxx’ 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.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.executeLoop(Unknown Source)
at com.sybase.jdbc3.jdbc.SybCallableStatement.execute(Unknown Source)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:70)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:342)
… 48 more

解决办法
1)在调用存储过程的代码
conn.setAutoCommit(true);//SET CHAINED OFF
CallableStatement cstmt = conn.prepareCall(“{call proc_xxx(?) }”);
//
conn.setAutoCommit(false);//SET CHAINED ON
2)或者在数据库中执行如下sql语句
sp_procxmode proc_xxx, “chained”

参考资料
http://forum.springsource.org/showthread.php?t=49398
http://manuals.sybase.com/onlinebook…iew/55096;hf=0
http://manuals.sybase.com/onlinebook…w/53740;hf=0#X

文章的脚注信息由WordPress的wp-posturl插件自动生成

此条目发表在javaee, spring分类目录,贴了, , , , , , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论链接可以 移除 nofollow.