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

来源:互联网 发布:关于网络利弊英语 编辑:程序博客网 时间:2024/05/21 07:07

 

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

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

Adaptive Server provides SQL standard-compliant “chained” transaction behavior as an option. In chained mode,all data retrieval and modification commands (delete,insert,open,fetch,select,and update) implicitly begin a transaction. Since such behavior is incompatible with many Transact- SQL applications,Transact-SQL style (or “unchained”) transactions remain the default.

举个例子  
In chained transaction mode,Adaptive Server implicitly executes a begin transaction statement just before the following data retrieval or modification statements: delete,insert,open,fetch,select,and update. For example,the following group of statements produce different results,depending on which mode you use: insert into publishers values ("9906",null,null,null) begin transaction delete from publishers where pub_id = "9906" rollback transaction In unchained transaction mode,the rollback affects only the delete statement,so publishers still contains the inserted row. In chained mode,the insert statement implicitly begins a transaction,and the rollback affects all statements up to the beginning of that transaction,including the insert.

本文出自:冯立彬的博客



原创粉丝点击