Insight mysql-connector connection 部分实现

来源:互联网 发布:一淘网跟淘宝网 编辑:程序博客网 时间:2024/05/21 05:17

疑问:和事务有关的操作,setTransactionIsolation ,setAutoCommit,commit做了什么处理?

setAutoCommit 和start transaction 有什么区别?

怎样实现读事务控制?

...

Insight mysql-connectorConnection实现ConnectionImpl。

...

直接上结论:

a. setTransactionIsolation 按照隔离级别,分别执行sql command:

"SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED";
"SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED";
"SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ";
"SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE";

b.setAutoCommit 执行sql command:

autoCommitFlag ? "SET autocommit=1" : "SET autocommit=0";

同start transaction 功能。

按照接口描述:If a connection is in auto-commit mode, than all its SQL statements will be executed and committed asindividual transactions
Otherwise, its SQL statements are grouped into transactions that are terminated by either commit() or rollback().



0 0
原创粉丝点击