DB service component construction method supporting multiple data sources

Through the DB service component construction method that supports multiple data sources, the performance and stability problems of database connection pools and data source bridges are solved, efficient data access and simplified application development are achieved, and data persistence and query performance are improved.

CN118939631APending Publication Date: 2024-11-12LONGYING ZHIDA (BEIJING) TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410990000.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

Unreasonable design of existing database connection pools may lead to excessive CPU usage, difficulty in positioning of connection pool resources, and data source bridges are affected by network delays and failures, resulting in unstable data transmission and requiring additional maintenance.

Method used

Adopt the DB service component construction method that supports multiple data sources, including establishing LDA data layer, loading mapping files, constructing session factories, creating session objects and entering executor operations, configuring data source properties through DefaultLdaClient, ShardingLdaClient supports Mysql and DB2 sub-libraries. Register to the Data Source Manager using custom expressions to route the library and incremental interval routing.

Benefits of technology

Effectively reduce database access pressure, improve data persistence capabilities and query performance, support unified transaction management and data caching, simplify application development, and be compatible with mainstream ORM frameworks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939631A_ABST
    Figure CN118939631A_ABST
Patent Text Reader

Abstract

The invention discloses a DB service component construction method supporting multiple data sources. The component construction method comprises the steps that S1, an LDA data layer is established; s2, loading a mapping file; s3, constructing a session factory; s4, creating a session object; and S5, entering an actuator for operation to obtain a database. The access pressure of the database is effectively reduced, the data persistence capability and the query plug pin are improved, and unified transaction management and data caching are supported.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database construction, and in particular to a method for constructing a DB service component supporting multiple data sources. Background Art

[0002] In complex business scenarios, application systems often need to access multiple data sources, and data persistence and query operations of multiple databases are not very friendly to developers. Therefore, this component designed and developed independently not only supports database persistence of a single database, but also supports persistence of multiple databases, and supports sub-libraries and sub-tables of multiple databases, making program development with multiple data sources more convenient and concise.

[0003] Existing relevant programs:

[0004] 1. Database connection pool: Use database connection pool to manage multiple database connections, thereby improving database performance and stability. Database connection pool can manage multiple database connections and allocate and release them as needed, thereby reducing the overhead of creating and closing database connections.

[0005] 2. Data source bridging: Use data source bridging technology to connect multiple data sources to achieve unified access to different data sources.

[0006] Data source bridging technology is usually implemented using middleware, such as JDBC bridging, ODBC bridging, etc.

[0007] The shortcomings of the prior art include:

[0008] Database connection pool: Improper connection pool design may lead to excessive CPU usage, and it is difficult to locate the source of connection pool resource leaks;

[0009] Data source bridging,Data source bridging may be affected by network latency and network failure,,resulting in unstable data transmission and requiring additional maintenance and,management. Summary of the invention

[0010] In view of the above problems, the present invention is proposed to provide a method for constructing a DB service component supporting multiple data sources, which overcomes the above problems or at least partially solves the above problems.

[0011] According to one aspect of the present invention, a method for constructing a DB service component supporting multiple data sources is provided, the component construction method comprising:

[0012] Step S1: Establish LDA data layer;

[0013] Step S2: Loading mapping file;

[0014] Step S3: construct a session factory;

[0015] Step S4: Create a session object;

[0016] Step S5: Enter the executor to perform operations and obtain the database.

[0017] Optionally, the step S1: establishing the LDA data layer specifically includes:

[0018] The default component client DefaultLdaClient configures data source related properties in the configuration document and is automatically loaded when the container starts based on DOM parsing.

[0019] Optionally, the step S2: loading the mapping file specifically includes:

[0020] Set sqlMapLocation, which is the storage path of the SQL configuration file. It supports wildcard configuration.

[0021] Optionally, the component scans the package path of the data source entity class and analyzes the SQL execution time. A threshold is set for the SQL execution time. If the threshold is exceeded, the component performs an alarm process.

[0022] The warning log has been output to the monitoring system. The default component client implements paging query based on the pagesize and pageNo sent by the application layer.

[0023] Optionally, the step S4: creating a session object specifically includes:

[0024] The ShardingLdaClient sharding client currently supports Mysql and DB2 databases. The sharding client plug-in uses custom expression routing and incremental interval routing to configure two or more data sources. A shard is a shard that represents the information of a data source and is registered in the data source manager.

[0025] Optionally, the expression routing sub-library supports customized data routing rules. The attributes used to define the rules support numeric types or string types. The rules are defined using the OGNL template language, using the tag language used in choose, when, if, otherwise, and incremental interval routing rules.

[0026] The present invention provides a method for constructing a DB service component supporting multiple data sources, the method comprising: step S1: establishing an LDA data layer; step S2: loading a mapping file; step S3: constructing a session factory; step S4: creating a session object; step S5: entering an executor to perform operations and obtain a database. The method effectively reduces the access pressure of the database, improves data persistence and query pins, and supports unified transaction management and data caching.

[0027] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0029] Figure 1 A flowchart of a method for constructing a DB service component supporting multiple data sources provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0031] The terms "comprises" and "having" and any variations thereof in the description embodiments, claims and drawings of the present invention are intended to cover non-exclusive inclusions, for example, including a series of steps or units.

[0032] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments.

[0033] like Figure 1 As shown, a method for constructing a DB service component that supports multiple data sources, the component construction method includes: step S1: establishing an LDA data layer; step S2: loading a mapping file; step S3: constructing a session factory; step S4: creating a session object; step S5: entering an executor to perform operations and obtain a database.

[0034] The default component client DefaultLdaClient configures data source related properties in the configuration document and is automatically loaded when the container starts based on DOM parsing.

[0035] First, in the required properties, set sqlMapLocation, which is the storage path of the SQL configuration file. Wildcard configuration is supported, such as classpath*:sqlMap_*.xml refers to all XML files starting with sqlMap_ under classes. Since LDA has loaded JDBC drivers for many data sources, you only need to configure the dataSource data source information here.

[0036] The component scans the package path of the data source entity class and analyzes the SQL execution time. The SQL execution time sets a threshold. If the threshold is exceeded, the component will issue an alarm and output it to the monitoring system in the form of a warn log. In addition, the default component client implements paging query based on the pagesize and pageNo sent from the application layer.

[0037] The ShardingLdaClient sharding client currently supports Mysql and DB2 databases. The sharding client plug-in uses custom expression routing sharding and incremental interval routing sharding, and configures two or more data sources. A shard is a shard that represents the information of a data source and is registered in the data source manager.

[0038] The expression routing sub-database supports custom data routing rules. The attributes used to define the rules support numeric types or string types. The rules are defined using the OGNL template language, using the choose, when, if, otherwise, and interval, shard and other tag languages ​​used in incremental interval routing rules.

[0039] Beneficial effects:

[0040] Diversity of data sources:

[0041] LDA supports connecting to and operating different types of data sources, such as relational databases (such as MySQL, Oracle, etc.) and non-relational databases (such as MongoDB, Cassandra, etc.). This allows applications to flexibly choose the data source that best suits their needs without having to write separate connection and operation code for each data source.

[0042] Data integration and unification:

[0043] LDA provides a unified data access interface, allowing applications to access data in different data sources in a unified way. This helps solve the problem of data being scattered in different data sources and makes data integration and unification easier.

[0044] High concurrency and high performance:

[0045] LDA usually has good concurrent processing capabilities and high performance, and can support a large number of concurrent database operations. This allows applications to better handle large-scale data processing and high-concurrency user access.

[0046] Simplify application development:

[0047] With LDA, applications do not need to care about the specific connection and operation details of the data source, but can perform data operations through the unified interface provided by LDA. This greatly simplifies the development and maintenance of applications and improves development efficiency.

[0048] The LDA component supports the configuration of multiple data sources and the ability to split databases, effectively reducing the access pressure on the database, improving data persistence and query pins, and supporting unified transaction management and data caching. It is also compatible with the mainstream ORM frameworks on the market.

[0049] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for constructing a DB service component supporting multiple data sources, characterized in that: The component construction method comprises: Step S1: Establish LDA data layer; Step S2: Loading the mapping file; Step S3: construct a session factory; Step S4: Create a session object; Step S5: Enter the executor to perform operations and obtain the database.

2. A method for constructing a DB service component supporting multiple data sources according to claim 1, characterized in that: The step S1: establishing the LDA data layer specifically includes: The default component client DefaultLdaClient configures data source related properties in the configuration document and is automatically loaded when the container starts based on DOM parsing.

3. A method for constructing a DB service component supporting multiple data sources according to claim 1, characterized in that: The step S2: loading the mapping file specifically includes: Set sqlMapLocation, which is the storage path of the SQL configuration file. It supports wildcard configuration.

4. A method for constructing a DB service component supporting multiple data sources according to claim 1, characterized in that: The component scans the package path of the data source entity class and analyzes the SQL execution time. The SQL execution time sets a threshold. If the threshold is exceeded, the component performs an alarm process. The warning log has been output to the monitoring system. The default component client implements paging query based on the pagesize and pageNo sent by the application layer.

5. A method for constructing a DB service component supporting multiple data sources according to claim 1, characterized in that: The step S4: creating a session object specifically includes: The ShardingLdaClient sharding client currently supports Mysql and DB2 databases. The sharding client plug-in uses custom expression routing and incremental interval routing to configure two or more data sources. A shard is a shard that represents the information of a data source and is registered in the data source manager.

6. A method for constructing a DB service component supporting multiple data sources according to claim 5, characterized in that: The expression routing sub-library supports customized data routing rules. The attributes used to define the rules support numeric types or string types. The rules are defined using the OGNL template language, using the tag language used in choose, when, if, otherwise, and incremental interval routing rules.

Citation Information

Patent Citations

  • Database routing device and method

    CN104408174A

  • Java-based data persistence assembly with built-in connection pool management function

    CN105302565A

  • Multi-source data query method and system

    CN107818127A

  • Method and system for improving computing performance by using distributed database architecture

    CN114780251A

  • Data source mechanism dynamic switching method

    CN115576918A