Data sources in spring

Source: Internet
Author: User
Tags connection pooling

http://yonguo.iteye.com/blog/115221

1) Spring in the third-party dependency package contains two data source implementation class package, DBCP data source, C3P0 data source, can be directly configured in spring use;

2) Get the Jndi data source: If the application is configured on a high-performance application server (such as WebLogic or WebSphere), we may prefer to use the data source provided by the application server itself;

The data source of the application server, using the Jndi open caller



3) Spring uses a multi-data source, in fact, the use of dynamic Data sources, to switch

http://blog.csdn.net/wangpeng047/article/details/8866239


4) spring transaction mechanism mainly includes declarative transaction and programmatic transaction, which focuses on declarative transaction, and programming transaction is not widely used in actual development;

5) Use Spring Annotated transaction management (also declarative transaction);


6) How the existing project is using the transaction;

Spring gets the data source through Jndi---"Build the data source factory from the data source (this step can be omitted)-----> build the transaction manager-----based on the data source factory"

Then through <tx:annotation-driven transaction-manager= "Txmanager"/>

You can use annotations to work with transactions;

7) Spring3 annotations do not support two data sources, SPRING4 can support


8) using the JTA bar, you can configure two data sources, using the same transaction;

That is, Java Transaction API,JTA allows applications to perform distributed transactions-access and update data on two or more network computer resources

However, compared with local transactions, the XA protocol has a large overhead and should be carefully considered in the system development process whether a distributed transaction is really required. If you do need a distributed transaction to reconcile multiple transactional resources, you should implement

and configuring the transactional resources for the supported XA protocol, such as JMS, JDBC database connection pooling, etc.




http://progress.iteye.com/blog/612222


9) Whether the data source is in a container or configured in a project:


1, in the Web container to manage the data source, then the system code will not touch the data source information, so as to protect the formal environment of the database security. For example, if a developer configures a test data source in a container, the code changes do not need to be modified in the future.

If you configure the data source in your project, the configuration information on the repository will be touched by the developer and will be at any time to cause a malfunction.


2, many containers in the configuration of the data source, once configured correctly, will be sensitive information encryption. In the project configuration data source, special handling is required.


3, the data source configured in the project basically adopts the third party library (DBCP, C3P0, Druid, etc.), can be replaced at any time, these open source products are focused on the connection pool of their own management optimization. Some of the data sources configured by the Web container will take into account the overall comprehensive performance to

and connectivity monitoring, such as the console provided by WebLogic provides a good management interface.


4, for often replace the data source connection information, feel in the project configuration convenient


This article is from the "Small Li Guangzhi Blog" blog, please be sure to keep this source http://6817977.blog.51cto.com/6807977/1597090

Data sources in 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.