In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "the realization method of apache shardingsphere transaction". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the implementation method of apache shardingsphere transaction".
Local transaction
TransactionTypeHolder.set (TransactionType.LOCAL)
Connection.setAutoCommit (true)
Statement.executeUpdate ("update user set name='kk' where id = 1")
Connection.commit () or commit.rollback ()
Put the transaction type in Threadlocal, default Local, so this sentence can be omitted
Execute setAutoCommit (true) on all ShardingConnection cached real Connection
Cache this operation in the jdbcMethodInvocations of ShardingConnection
During execution, if you need to create a new real Connection, setAutoCommit (true) will also be executed on the new Connection.
Performing setAutoCommit (true) in a new connection is achieved through jdbcMethodInvocations
New connections will also be cached
Commit or rollback is also performed on the real Connection of all ShardingConnection caches
DataSource dataSource = ShardingDataSourceFactory.createDataSource (datasourceMap, shardingRuleConfig, pros); Connection connection = null; try {connection = dataSource.getConnection (); connection.setAutoCommit (false); Statement statement = connection.createStatement (); statement.executeUpdate ("update user set name = 'meichaofeng' where ex_id = 201"); connection.commit (); statement.close () Connection.close ();} catch (SQLException e) {try {connection.rollback ();} catch (SQLException E1) {e1.printStackTrace () }} Thank you for your reading. The above is the content of "the implementation method of apache shardingsphere transaction". After the study of this article, I believe you have a deeper understanding of the implementation method of apache shardingsphere transaction, and the specific use needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.