Talking about the use of JEECG multi-data source

Source: Internet
Author: User

first, the simple introduction of what is JEECG? jeecg(ee code Generation) is a free and open source fast development platform based on the code generator, using JEECG to quickly and easily develop an enterprise-class Web Application System. JEECG advocates that simple functions are generated directly by code generators, that complex services are customized using forms, and that business processes use workflows to implement and extend task interfaces, and developers write special business logic.

let's focus on the followingJeecg3.5gathe use of version multi-data sources. Before we use multiple data sources, it is necessary to understand what a multi-data source is. Why do we need to use multiple data sources? A multi-data source refers to data that is processed in the same system from a different data source. For example, we are usingEtlwhen doing data synchronization, cleaning and integration often to configure the source library, integration library, cleaning library, target library, etc., so many data sources, we need to adopt a flexible mechanism configuration, to ensure free switching between data sources. JEECG3.5provides the capability of a multi-data source,Jeecgthe design of multi-data sources directly utilizesSpringjdbcconnection, withHibernate,Mybatisis not related to the persistence framework, we use the most primitiveJdbcconnection, simple and convenient. Jeecgin the databaseT_s_data_sourcetables are used to store dynamic data sources, and the system starts with aOrg.jeecgframework.web.system.listener.InitListenerputT_s_data_sourceall Dynamic Data source information in the table is configured to the staticMap, in whichT_s_data_source.db_keyfield asMapof theKey, toT_s_data_sourcethe entity class asValue.

Below is a brief description of how to multiple data sources are used in JEECG3.5GA.

    1. Configure the multi-data source Management menu and assign permissions.

(1) Configure the multi-data source Management menu.

find data source configuration control class, you can easily see the data source configuration url is dynamicdatasourcecontroller.do?dbsource

Enter " System Management " à " Menu Management " , Click "Menu Entry" to enter the menu information as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/78/wKioL1VKFUWgog-NAAJYSGld72s030.jpg "title=" A.png " alt= "Wkiol1vkfuwgog-naajysgld72s030.jpg"/>

where the menu address is: Dynamicdatasourcecontroller.do?dbsource , click " Determine " button to save the menu information.

(2) Assign a menu permission to a role.

Enter " System Management " à " role Management, click Permissions Settings under Role list, load menu list, tick the check box in front of multiple data source management, click the Save icon next to menu list to save Role menu permissions.


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/7D/wKiom1VKFHOA7BCnAAPQFv8TKIU021.jpg "title=" B.png " alt= "Wkiom1vkfhoa7bcnaapqfv8tkiu021.jpg"/>

(3) exit the system to log back in. You can see the "Multiple Data source management" menu added in System Management.

    1. Input data source information.

(1) Enter " System Management " à " multiple data source management, go to the following page.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6C/78/wKioL1VKFiCiZymOAAGy4rjE7fU430.jpg "title=" C.png " alt= "Wkiol1vkficizymoaagy4rje7fu430.jpg"/>

(2) Click " input " , input data source information, and save.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/7D/wKiom1VKFQjDwkJqAAEfzhpHYEo980.jpg "title=" D.png " alt= "Wkiom1vkfqjdwkjqaaefzhphyeo980.jpg"/>

Note: Each time you add or edit a data source, the system dynamically refreshes the data source information in the cache.

    1. Use multiple data sources dynamically.

Please see the Org.jeecgframework.core.util.DynamicDBUtil tool class for each method used . Focus on the following three methods:

Public Static list<map<string, object>> findlist (final string dbkey, String sql, Object ... param);

public   static  object findOne ( final

Public Static int Update (finalstring dbkey, String sql, Object ... param);

Create The Service implementation class, while the page must upload the Dbkey to invoke the data source .

   /**

     * Dynamic Data Source testing

     * @param Dbkey Data Source KEY

     * @return

*/

public list<map<string,object>> querydynamicdb (String dbkey) {

final String sql = "SELECT * from Tbl_sys_user";

List<map<string,object>> userlist = dynamicdbutil. Findlist(Dbkey, SQL, null);

return userlist;

}

the above is my Jeecg3.5ga A simple analysis of the use of multiple data sources, through the above analysis we know that JEECG data sources in the database, convenient and flexible management and maintenance of data sources, while using SPRINGJDBC for multi-data source processing, Simple and direct, at the same time high efficiency.


Talking about the use of JEECG multi-data source

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.