---
title: "Can't start a cloned connection while in manual transaction mode  "
author: "onlyor"
date: "2012-04-17T17:20:28Z"
tags: []
categories: ["编程语言"]
slug: "can-t-start-a-cloned-connection-while-in-manual-transaction-mode"
draft: false
lastmod: "2012-04-17T17:26:49Z"
id: 1488652
url: "https://onlyor.iteye.com/blog/1488652"
---

### Can't start a cloned connection while in manual transaction mode

为了保证多个sql全部执行成功后再提交，执行以下语句

conn.setAutoCommit(false);

然后执行多个执行语句后

conn.commit();

出现Can't start a cloned connection while in manual transaction mode异常。

 

原因：一般为在SQL SERVER的JDBC连接上执行多个STATEMENTS的操作，

用手动提交事务状态（AutoCommit=false) 并且使用**默认的模式** (SelectMethod=direct)

 

解决办法

（1）  
当你使用手动事务模式时，必须把**SelectMethod 属性的值设置为 Cursor**。

把URL加入 ";**SelectMethod=cursor"** 即可。

（2）

保证只执行一条语句