是否存在“设置链接"的错误?在net.sourceforge.jtds.jdbc.Driver中的setAutoCommit()中? [英] Is there a bug with "set chained" in setAutoCommit() in net.sourceforge.jtds.jdbc.Driver?

查看:356
本文介绍了是否存在“设置链接"的错误?在net.sourceforge.jtds.jdbc.Driver中的setAutoCommit()中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对net.sourceforge.jtds.jdbc.Driver

源代码说:

2161  if (serverType == Driver.SYBASE) {
2162            if (autoCommit) {
2163                sql.append("SET CHAINED OFF");
2164            } else {
2165                sql.append("SET CHAINED ON");
2166            }

但是,是不是应该倒退,并且autoCommit == false的链接应该为OFF?

我遇到此问题的原因如下:

The reason I ran into this is as follows:

我正在编写一个Java应用程序,该应用程序需要执行一些复杂的SQL并在所有应用程序失败的情况下将其全部回滚:

I am writing a Java app which needs to do some complicated SQL and roll back all of it if any of it fails:

  • 使用net.sourceforge.jtds.jdbc.Driver

调用setAutoCommit(false)

Call setAutoCommit(false)

执行SQL1

调用存储的过程'MySP1'

Call stored proc 'MySP1'

  • 存储的proc MySP1'不受我控制

  • Stored proc MySP1' is NOT under my control

它具有EXEC sp_procxmode 'dbo.MySP1','unchained'

执行SQL2

如果SQL2失败,请回滚所有内容(包括SQL1),否则进行提交.

If SQL2 fails, roll back everything (including SQL1), otherwise commit.

完成此操作后,我从MySP1中收到以下错误:

Having done that, I get the following error from MySP1:

 Stored procedure 'MySP1' may be run only in unchained transaction mode. The 'SET CHAINED OFF' command will cause the current session to use unchained transaction mode.

推荐答案

我遇到了几乎相同的问题,并通过运行以下SQL解决了该问题.希望它能对您有所帮助.

I had almost the same problem and solved it by running following SQL. hopefully it can help you.

sp_procxmode your_stored_Procedure, 'anymode'

在您的情况下 your_stored_Procedure = MySP1 ,则应运行以下代码:

in your case your_stored_Procedure = MySP1 then you should run following code:

 sp_procxmode MySP1, 'anymode'

这篇关于是否存在“设置链接"的错误?在net.sourceforge.jtds.jdbc.Driver中的setAutoCommit()中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆