java - Is there a bug with "set chained" in setAutoCommit() in net.sourceforge.jtds.jdbc.Driver? -


i having confusion set chained statement in setautocommit() method in net.sourceforge.jtds.jdbc.driver

the source code says:

2161  if (servertype == driver.sybase) { 2162            if (autocommit) { 2163                sql.append("set chained off"); 2164            } else { 2165                sql.append("set chained on"); 2166            } 

however, shouldn't backwards, , chaining should off autocommit==false?


the reason ran follows:

i writing java app needs complicated sql , roll of if of fails:

  • open sybase connection using net.sourceforge.jtds.jdbc.driver

  • call setautocommit(false)

  • do sql1

  • call stored proc 'mysp1'

    • stored proc mysp1' not under control

    • it has exec sp_procxmode 'dbo.mysp1','unchained'

  • do sql2

  • if sql2 fails, roll (including sql1), otherwise commit.

having done that, following error mysp1:

 stored procedure 'mysp1' may run in unchained transaction mode. 'set chained off' command cause current session use unchained transaction mode. 

i had same problem , solved running following sql. can you.

sp_procxmode your_stored_procedure, 'anymode' 

in case your_stored_procedure = mysp1 should run following code:

 sp_procxmode mysp1, 'anymode' 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -