ADO.NET unified affairs, and connecting pool management (1)

xiaoxiao2021-04-05  229

First, the primer

In a hierarchical architecture, the business layer typically needs to call multiple data access layer (DAO) methods to implement one complete business data processing, which requires considering the unified management of transactions. In addition to the heavyweight COM , can there be a lightweight transaction management method? I think a long time, I have also posted a good party at 9CBS.

Second, the solution

After several trials, decided to learn from the concept of JTA in Java, bind database connections and threads, and transactions started in the same thread. Finally, it is not exclusive. Specifically follow the following:

1. Unified management transaction and database connections by 'transaction manager', preventing instances of database connections from passing in layers in each layer method, and even seeing transactions and connections in some levels, only feels objects.

2, 'Transaction Manager' can different data sources, that is, the database connection manager needs to be abstracted.

3. The transaction started in the same thread is the same transaction. Place the database to the HashTable and CurrentTread as Key.

4, give the logo attribute of the database transaction (such as whether the transaction has started) THREADSTATIC.

转载请注明原文地址:https://www.9cbs.com/read-132055.html

New Post(0)