Transaction processing: databse JDBC MyBatis Spring

Source: Internet
Author: User

The understanding of affairs requires a rather lengthy process, which is slowly understood in practice, and then strengthened by the relevant theoretical basis. Transactions in the database:

Traditional local transaction processing relies on the database's own transaction processing power, and the transaction itself is the cornerstone of the traditional relational database. Simply put, a transaction is some SQL that satisfies the acid characteristics, and the database implements these mechanisms through locks and logs. The domestic MySQL INNODB transaction engine has a large number of primers, and there are many articles that allow us to understand the concepts of indexing and transactions in depth. Here is a brief talk about my understanding;

A: To represent atomicity, it is best to understand, to either do it all or not to do it all.

C: Consistency, the simple thing is you buckle 50, someone added 50 (consistency itself there are many kinds, traditional understanding database is strong consistency)

I: Isolation, the visible line between transactions, it is very abstract, in fact, look at the isolation level of 4, do an experiment, it is very good understanding. For example, most databases on the market have the default isolation level of Read committed data, so only updates that have been submitted after other transactions can be sensed.

But there's a fun and a core transaction. Create a payment order to use for reuse, if a transaction a inserts a single piece of data, another transaction B inserts the same data (the primary key is the same), even if another transaction does not commit, it will hold the primary key conflict. This is fun. Can be experimented with.

D: Persistence, once committed, will not be lost. But who can guarantee that will not be lost, natural and natural disasters. In fact, this is the transaction log commits the persistent redo log, even if the power outage, the in-memory data is not persisted to the disk, the use of redo log recovery, I recovered, used to learn Aries Recovery algorithm.

Transactions in JDBC

For Java programmers, there is no need to directly use those SQL operations database, we use JDBC, each database vendor will provide drivers for some programming languages, it sounds high-end, is actually a database communication API, internal communication through the database's own protocol. JDBC is a standard interface that each vendor implements, and then we operate basically the same for different databases. Architecture like, the most important thing is this connection, I have specifically done the experiment, want to know something about it. In MSYQL show processlist can view the currently executing thread and find that each connection corresponds to a processing thread, the commit transaction and the rollback transaction are the connection processing, and of course the send SQL and receive result collection is it. So the local transaction process is still on the database itself.


JDBC-driven architecture

The JDBC driver to implement the interface is in the JDK Rt.jar in the package Java.sql,idea in the tool can directly see the class directly within the relationship, very cool. See, of course there is another diagram, is a SQL-related exception, a project how to set up a canonical anomaly system, the latter time to summarize.

Spring transaction processing (pending research)

Spring's transaction management ultimately needs to rely on the database's own transaction management, but it provides a very important function at the business layer is the propagation of the transaction. Very fun, generally in the development process, we are using the default transmission mechanism.

Distributed transaction theory (pending research)

CAP:

BASE:

Conformance protocol: Two-stage, three-stage, Paxos method (zookeeper based on this implementation, too complex to learn), raft (known as a simple and easy to implement consistency algorithm, ready for a detailed look)

Transaction processing: databse JDBC MyBatis Spring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.