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

本文介绍了解决在使用JAVA和JDBC驱动JTDS1.2调用SYBASE12.5存储过程中遇到的问题,即存储过程只能在Unchained模式下运行的情况。文中提供了一种解决方案,即将存储过程及其相关过程的运行模式设置为anymode。

 

通过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.

本文出自:冯立彬的博客



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值