I am using ScriptRunner class For running SQL scripts For SQL SERVER 2005 Data base. It is giving me following error for insertion queries other queries for deletion or selection is working fine.
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot invoke a rollback operation when the AutoCommit mode is set to "true".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.rollback(Unknown Source)
at com.ibatis.common.jdbc.ScriptRunner.runScript(ScriptRunner.java:222)
at com.ibatis.common.jdbc.ScriptRunner.runScript(ScriptRunner.java:114)
Of course you can't rollback when autocommit is on. If you need rollback, you must turn autocommit off. Or use a transaction, which is a posh way of turning autocommit off.
Thanks Campbell, I tried with some <prop key="hibernate.connection.autocommit">false</prop> for doing auto commit false from my spring application context file. As well as tried to off auto commit of Database SQL SERVER 2005 by using command SET IMPLICIT_TRANSACTIONS { ON } but it is giving same error to me.
Arpit Aggarwal wrote:Thanks Campbell, I tried with some <prop key="hibernate.connection.autocommit">false</prop> for doing auto commit false from my spring application context file. As well as tried to off auto commit of Database SQL SERVER 2005 by using command SET IMPLICIT_TRANSACTIONS { ON } but it is giving same error to me.
Don't you pass the autocommit property as a parameter in ScriptRunner's constructor?