JAVA 执行SQL语句报异常(SQL SERVER)

执行完SQL后捕获异常commit() should not be called while in auto-commit mode.

解决办法:

添加 con.setAutoCommit(false);

例子如下:

con.setAutoCommit(false);
try{
execute(sql1);
execute(sql);
con.commit();
}catch(Exception e){
con.rollback();
}

posted on 2012-12-24 15:30  青春丶冭柔情  阅读(672)  评论(0编辑  收藏  举报

导航