【发布时间】:2013-03-15 07:50:05
【问题描述】:
假设我的代码大致类似于以下内容:(使用 oracle 10G jdbc)。在这种特定场景下会提交事务吗?
public void someMethod(){
try {
OracleConnection connection = getConnectionFromPool();
connection.setAutoCommit(false);
// Do some transaction here - complete transaction, no errors occurred
...
//Throw my own exception here
throw new Exception("Custom Exception");
} catch (Exception e}
{
...
}
finally {
connection.setAutoCommit(true);
}
}
【问题讨论】:
-
不,如果没有错误,您必须提交()事务,否则回滚。
-
当你尝试时会发生什么?
-
@Sudhanshu:不符合 JDBC JavaDocs(见我的回答)。