alien007 发表于 2008-04-08 17:12

[求助]为什么我就得不到数据呢? 大虾请进

环境

SYBASE 12.5

hibernate 3.0
JDBC driver jconn2


我写了个SP

内容大概是

create #a()

insert into #a
select * from b

select * from #a

drop #a

在sybase client sp通过编译 运行正常
但用hibernate连接 throw exception
The 'CREATE TABLE' command is not allowed within a multi-statement transaction in the 'tempdb' database.


请帮我看一下

hobbylu 发表于 2008-04-08 18:34

为tempdb设置上ddl in tran数据库选项

alien007 发表于 2008-04-08 18:46

回复 #2 hobbylu 的帖子

了解 除了这个呢
我用jdbc连没事
但用hibernate 连就抱错

flybean 发表于 2008-04-09 08:38

AUTOCOMMIT不同(set chained)
JDBC取得的连接是默认的,autocommit = true,也即set chained off
HIBERNATE中启动了JDBC管理的事务,会set autocommit = false,也即set chained on

可参考:http://www.sybaseclub.org/twiki/bin/view.cgi/ASE/ASEProgrammingFAQ

alien007 发表于 2008-04-09 11:28

:P 谢谢两位的指导~

alien007 发表于 2008-04-09 13:34

回复 #4 flybean 的帖子

按照你的方法 我去看了一下
   default autocommit value

jdbc         true
hibernate false

但是我用setAutoCommit(true)方法来达到jdbc一样的环境
但是throw exception

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

why? how to solve it in Hibernate ?

alien007 发表于 2008-04-09 19:38

后来我用了hibernate.properties来设置autocommit = true, 奇怪居然通过了 没抛任何异常
后来改用spring提供得HibernateSupport来impl 没出现上述异常

我就是闹不明白为什么 我在程序中用setAuntoCommit(true)方法来运行 就是通不过呢 为什么要在properties文件里就好用呢
页: [1]
查看完整版本: [求助]为什么我就得不到数据呢? 大虾请进