JAVA调用SYBASE过程报过程模式不对的处理

通过JAVA、JDBC驱动为JTDS1.2调用SYBASE12.5存储过程的时候,老是报该过程只允许在"Unchained"模式下运,通过命令sp_procxmode查看的时候,该过程也是"Unchained"模式,Hibernate报运行命令"setchainedoff"即可将当前库的存储过程运行模式改为"Unchianed",但执行后也不行;后面在一个国外的网站查到,将其运行模式改为"anymode"即可,采用命令:sp_procxmode过程名'anymode',但要修改所有与该过程相关的,被该过程调用的模式都为"anymode"才行,据说只有Sybase有这个毛病,其它的数据库都没有这个问题。

注:chained和Unchained的分别简单的说,就是chained会自动起事务;Unchained不会自动启事务,需要用户显性的用begintran..commit/rollback去定义。下面是英文说明:

AdaptiveServerprovidesSQLstandard-compliant“chained”transactionbehaviorasanoption.Inchainedmode,alldataretrievalandmodificationcommands(delete,insert,open,fetch,select,andupdate)implicitlybeginatransaction.SincesuchbehaviorisincompatiblewithmanyTransact-SQLapplications,Transact-SQLstyle(or“unchained”)transactionsremainthedefault.

举个例子
Inchainedtransactionmode,AdaptiveServerimplicitlyexecutesabegintransactionstatementjustbeforethefollowingdataretrievalormodificationstatements:delete,insert,open,fetch,select,andupdate.Forexample,thefollowinggroupofstatementsproducedifferentresults,dependingonwhichmodeyouuse:insertintopublishersvalues("9906",null,null,null)begintransactiondeletefrompublisherswherepub_id="9906"rollbacktransactionInunchainedtransactionmode,therollbackaffectsonlythedeletestatement,sopublishersstillcontainstheinsertedrow.Inchainedmode,theinsertstatementimplicitlybeginsatransaction,andtherollbackaffectsallstatementsuptothebeginningofthattransaction,includingtheinsert.

<!--EndFragment-->

你可能感兴趣的:(java,Hibernate,jdbc,Sybase)