Can't start a cloned connection while in manual tr

原因
在手工事务模式 (AutoCommit=false) 下,如果使用直接 (SelectMethod=direct) 模式,当您尝试对使用 JDBC 2000驱动程序的 SQL Server 数据库执行多个语句时,将会出现此问题。直接模式是该驱动程序的默认模式。
回到顶端

解决方案
当您使用手工事务模式时,必须将驱动程序的 SelectMethod 属性设置为 Cursor,或者确保您按照本文“更多信息”一节指定的方式在每个连接上只使用一个活动语句


解决方法:
<property name="connection.username">***</property>
 <property name="connection.url">
  jdbc:microsoft:sqlserver://192.168.18.254:1433;DatabaseName=comjt;SelectMethod=Cursor
 </property>
 <property name="dialect">
  net.sf.hibernate.dialect.SQLServerDialect
 </property>
 <property name="myeclipse.connection.profile">t</property>
 <property name="connection.password">***</property>
 <property name="connection.driver_class">
  com.microsoft.jdbc.sqlserver.SQLServerDriver
 </property>
 <property name="show_sql">true</property>
 <property name="connection.useUnicode">true</property>
 <property name="connection.characterEncoding">GBK</property>

 

补:

这个原因说的详细也有建议

If you pass "SelectMethod=cursor" attribute in connectio url, will allow more than one active statement per connection." jdbc:microsoft:sqlserver://localhost:1433;SelectMethod=cursor;","user","pwd"The reason for this is;When SelectMethod is set to direct, SQL Server does not support multiple active statements on a single connection within a transaction; however, when auto-commit mode is enabled (the default), the Microsoft SQL Server JDBC driver provides the ability to have multiple JDBC statements open on a single JDBC connection. This is done by cloning physical SQL Server connections as needed. To avoid cloning physical SQL Server connections in this circumstance, you should create only one Statement, PreparedStatement, CallableStatement, or DatabaseMetaData object per JDBC Connection object. Be sure to invoke the "close" methods on these objects when you are finished with them, that is, before creating another object of the types described.Sridhar PaladuguMicrosoft Developer SupportJDBC Webdata
还有使用2005的jdbc驱动时,数据库用  SQL Server2005 时,不会出现这个问题,一切正常,2005的jdbc驱动不支持SelectMethod=Cursor(不知道是不是,不过运行是说这个语法有错误,可能不是这样写)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值