今天用jdbc连接sqlserver数据库,在进行操作的时候报错:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]
Can't start a cloned connection while in manual transaction mode.
Google了一下,解决了:就是在url后面加上SelectMethod=cursor
url="jdbc:microsoft:sqlserver://192.9.107.61:1433;DatabaseName=rone;SelectMethod=cursor"
原因,比较权威的解释:
You have to add a property to the pool definition, something to do with selectMode=cursor or selectMethod=cursor. Check the driver documentation. Otherwise the driver will not allow more than one statement per connection at any given time。
This error occurs when you try to execute multiple statements against a SQL Server database with the JDBC driver while in manual transaction mode (AutoCommit=false) and while using the direct (SelectMethod=direct) mode. Direct mode is the default mode for the driver.