Data source connection pool control method and device, and server
By deploying middleware on the server and adopting a middleware connection strategy to release database connections based on data reception time, the problem of poor resource access capability when querying historical data in existing technologies is solved, and more efficient data connection management is achieved.
Patent Information
- Application Number
- CN202211084663.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-06
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2042-09-06
AI Technical Summary
In the prior art, when querying historical data, it is necessary to wait until all database queries are completed before releasing the connection, resulting in poor database connection resource calling capability.
By deploying middleware on the server, data source configuration information is obtained, and a middleware connection strategy is adopted to release the database connection based on the data reception time, allowing the connection to be released immediately upon receiving the target data.
The resource management of the data source connection pool has been optimized, which has improved data connection efficiency, reduced resource usage, and solved the problem of poor database connection resource calling capability.
Smart Images

Figure CN115422277B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to database technology, and in particular to a data source connection pool control method and device and a server. BACKGROUND
[0002] At present, with the transformation of commercial banks, the use scenarios of big data are increasingly rich, especially the application scenarios of querying, analyzing and utilizing historical data.
[0003] In the prior art, when storing historical data, multiple historical databases are divided according to the data time range, and the historical data is stored. Each historical database is deployed in a separate server. When querying historical data, the server running the application connects all the historical databases. After traversing all the databases to query the result data, the connection between the server and the historical database is released, and the result data of the query is loaded on the front end of the server and provided to the data user.
[0004] However, in the prior art, the connection between the server and the historical database needs to be released after traversing all the databases to query the result data. If the speed of querying any historical database is fast, all the connections need to be released after all the historical databases are queried, which leads to more resources occupied by the query operation, and further leads to poor resource calling ability of the database connection. SUMMARY
[0005] The present application provides a data source connection pool control method, device and server to solve the technical problem of poor resource calling ability of the database connection.
[0006] In a first aspect, the present application provides a data source connection pool control method, which comprises:
[0007] Obtaining data source configuration information of the server through middleware deployed in the server running the application; wherein the data source configuration information represents the configuration information of the data source connection pool of the server, and the configuration information includes the database connection strategy of the server;
[0008] In response to an editing operation on the database connection strategy, determining that the database connection strategy of the server is a middleware connection strategy; wherein the middleware connection strategy is used to release the connection between the server and the database according to the receiving time of the server receiving the data of the database;
[0009] In response to a query instruction, wherein the query instruction is used to instruct to query target data from multiple target databases, and receiving target data sent by each target database in the multiple target databases;
[0010] Based on the middleware connection strategy, if it is determined that target data sent by any of the plurality of target databases has been acquired, then the connection between any of the target databases and the server is released according to the acquisition time of any target data.
[0011] Further, the response to the editing operation for the database connection strategy is to determine that the database connection strategy of the server is a middleware connection strategy, comprising:
[0012] In response to the editing operation for the database connection strategy, the initial strategy of the database connection strategy is updated to a middleware connection strategy.
[0013] Further, in response to the query instruction, target data sent by each of the plurality of target databases is received, comprising:
[0014] In response to the query instruction, wherein the query instruction includes query condition information, the target database corresponding to the query condition information is determined according to the data source configuration information, and the query condition information is sent to the target database; wherein the query condition information is used to query and acquire target data;
[0015] The target data sent by the target database is received.
[0016] Further, in response to the query instruction, the target database corresponding to the query condition information is determined according to the data source configuration information, comprising:
[0017] In response to the query instruction, wherein the query instruction includes query condition information, the business module corresponding to the query condition information is determined; wherein the business module is a pre-set module corresponding to a business type, and each business module corresponds to different data source configuration information; the data source configuration information of the business module is determined.
[0018] The target database corresponding to the query condition information is determined according to the data source configuration information of the business module; wherein the query condition information is used to query and acquire target data.
[0019] Further, the method further comprises:
[0020] If it is determined that the business module is a preset listening module, wherein the listening module is used to indicate that the server includes code information for listening, a data source connection configuration strategy for accessing the target database is generated; wherein the data source connection configuration strategy includes access step information of the target database, and the access step information includes a query step corresponding to the query condition information and a listening step corresponding to the code information.
[0021] Further, the method further comprises:
[0022] receiving the connection log sent by the target database; wherein the connection log comprises the acquisition time of the target data.
[0023] Further, based on the middleware connection strategy, if it is determined that the target data in any of the plurality of target databases has been acquired, the connection between the any target database and the server is released according to the acquisition time of the any target data, comprising:
[0024] if it is determined that the target data in any of the plurality of target databases has been acquired, the acquisition time of the any target data is determined according to the connection log sent by the any target database;
[0025] based on the middleware connection strategy and the acquisition time of the any target data, the connection between the target database corresponding to the any target data and the server is released.
[0026] Further, the configuration information of the data source connection pool further comprises a plurality of data sources; the method further comprises:
[0027] if it is determined that the data source in the acquired configuration information has been changed, the data source configuration information corresponding to the selection operation is obtained in response to the selection operation;
[0028] wherein the selection operation comprises any one or more of the following:
[0029] adding a data source, deleting a data source, modifying a data source, and querying a data source.
[0030] Further, the data source configuration information comprises a connection address for a database, a maximum number of connections for a database, an initial number of connections for a database, and user information.
[0031] In a second aspect, the application provides a data source connection pool control device, the device comprising:
[0032] an acquisition unit configured to acquire data source configuration information of a server by a middleware deployed in the server running an application; wherein the data source configuration information represents the configuration information of the data source connection pool of the server, and the configuration information comprises a database connection strategy of the server;
[0033] a determination unit configured to determine the database connection strategy of the server as a middleware connection strategy in response to an editing operation on the database connection strategy; wherein the middleware connection strategy is used to release the connection between the server and the database according to the receiving time of the data received by the server from the database;
[0034] a receiving unit, configured to receive target data sent by each of the plurality of target databases in response to a query instruction, wherein the query instruction is used to instruct to query target data from the plurality of target databases;
[0035] a releasing unit, configured to, based on the middleware connection strategy, if it is determined that the target data sent by any of the plurality of target databases has been acquired, release the connection between the any of the plurality of target databases and the server according to the acquisition time of the any of the target data.
[0036] Further, the determining unit is specifically configured to:
[0037] update the initial strategy of the database connection strategy to the middleware connection strategy in response to an editing operation on the database connection strategy.
[0038] Further, the receiving unit comprises:
[0039] a first determining module, configured to, in response to a query instruction, determine a target database corresponding to query condition information according to data source configuration information, and send the query condition information to the target database, wherein the query condition information is used to query and acquire target data.
[0040] a first receiving module, configured to receive target data sent by the target database.
[0041] Further, the first determining module comprises:
[0042] a first determining submodule, configured to, in response to a query instruction, determine a business module corresponding to query condition information, wherein the business module is a module corresponding to a business type and is pre-set, each business module corresponds to different data source configuration information, and the data source configuration information of the business module is determined.
[0043] a second determining submodule, configured to determine a target database corresponding to the query condition information according to the data source configuration information of the business module, wherein the query condition information is used to query and acquire target data.
[0044] Further, the apparatus further comprises:
[0045] The generating unit is configured to generate a data source connection configuration strategy for accessing the target database if it is determined that the service module is a preset monitoring module, wherein the monitoring module is configured to instruct the server to include code information for monitoring, and the data source connection configuration strategy includes access step information of the target database, and the access step information includes a query step corresponding to the query condition information and a monitoring step corresponding to the code information.
[0046] Further, the apparatus further comprises:
[0047] The second receiving module is configured to receive a connection log sent by the target database, wherein the connection log includes a target data acquisition time.
[0048] Further, the releasing unit comprises:
[0049] The second determining module is configured to determine a target data acquisition time of any target data according to a connection log sent by any target database if it is determined that the target data in the any target database has been acquired.
[0050] The releasing module is configured to release a connection between a target database corresponding to any target data and the server based on the middleware connection strategy and the target data acquisition time.
[0051] Further, the configuration information of the data source connection pool further includes a plurality of data sources, and the apparatus further comprises:
[0052] The selecting unit is configured to obtain data source configuration information corresponding to a selection operation in response to a determination that a data source in the acquired configuration information has been changed.
[0053] The selection operation includes any one or more of the following:
[0054] Adding a data source, deleting a data source, modifying a data source, and querying a data source.
[0055] Further, the data source configuration information includes a connection address for a database, a maximum number of connections for the database, an initial number of connections for the database, and user information.
[0056] In a third aspect, the present application provides a server, comprising a memory and a processor, wherein the memory stores a computer program capable of running on the processor, and the processor executes the computer program to implement the method of the first aspect.
[0057] In a fourth aspect, the present application provides a computer readable storage medium, wherein the computer readable storage medium stores computer execution instructions, and the computer execution instructions are used to implement the method in the first aspect when executed by a processor.
[0058] In a fifth aspect, the present application provides a computer program product, comprising a computer program, and the computer program is used to implement the method in the first aspect when executed by a processor.
[0059] The data source connection pool control method, device and server provided by the present application are characterized in that: the middleware deployed in the server running an application is used to obtain the data source configuration information of the server; wherein the data source configuration information represents the configuration information of the data source connection pool of the server, and the configuration information comprises the database connection strategy of the server. In response to an editing operation on the database connection strategy, the database connection strategy of the server is determined to be a middleware connection strategy; wherein the middleware connection strategy is used to release the connection between the server and the database according to the receiving time of the data received by the server from the database. In response to a query instruction, wherein the query instruction is used to instruct to query target data from a plurality of target databases, and the target data sent by each target database in the plurality of target databases is received. Based on the middleware connection strategy, if it is determined that the target data sent by any target database in the plurality of target databases has been obtained, the connection between the server and the target database is released according to the obtaining time of the target data. In the present application, the middleware deployed in the server running an application is used to obtain the data source configuration information of the server, the database connection strategy of the server is determined to be a middleware connection strategy, then, according to the received query instruction, the query instruction is sent to the plurality of target databases, when the target data corresponding to the query instruction is found by the target database and sent to the server, the target data sent by each target database in the plurality of target databases is received by the server. Based on the middleware connection strategy, if it is determined that the target data in any target database in the plurality of target databases has been obtained, the connection between the server and the target database is released according to the obtaining time of the target data, that is, the connection is released according to the time of obtaining the target data, without waiting for all the target information of the target databases to be obtained before releasing the connection. Therefore, the middleware can assist the server in managing the data source connection demand, the data source configuration information of the server is managed by using the middleware method when the application is deployed, and the program architecture in the server is decoupled by using the interface calling method. At the same time, by using the present application, the resource management of the data source connection pool can be optimized, the connection pool resources can be dynamically released by dynamic analysis, the efficiency of data connection can be improved, the occupied resources are reduced, and the technical problem of poor resource calling ability of the database connection is solved. BRIEF DESCRIPTION OF DRAWINGS
[0060] The accompanying drawings, which are incorporated herein and constitute part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, further serve to explain the principles of the present disclosure.
[0061] Figure 1 A flowchart of a data source connection pool control method provided for an embodiment of the present application is shown in FIG. 1.
[0062] Figure 2 A flowchart of another data source connection pool control method provided for an embodiment of the present application is shown in FIG. 2.
[0063] Figure 3 A structural diagram of another data source connection pool control device provided for an embodiment of the present application is shown in FIG. 3.
[0064] Figure 4 A flowchart of another data source connection pool control method provided for an embodiment of the present application is shown in FIG. 4.
[0065] Figure 5 A scenario diagram of another data source connection pool control method provided for an embodiment of the present application is shown in FIG. 5.
[0066] Figure 6 A flowchart of another data source connection pool control method provided for an embodiment of the present application is shown in FIG. 6.
[0067] Figure 7 A flowchart of another data source connection pool control method provided for an embodiment of the present application is shown in FIG. 7.
[0068] Figure 8 A structural diagram of a data source connection pool control device provided for an embodiment of the present application is shown in FIG. 8.
[0069] Figure 9 A structural diagram of another data source connection pool control device provided for an embodiment of the present application is shown in FIG. 9.
[0070] Figure 10 A structural diagram of a middleware provided for an embodiment of the present application is shown in FIG. 10.
[0071] The above drawings have shown specific embodiments of the present disclosure, and more detailed descriptions will be given hereinafter. These drawings and descriptions are not intended to limit the scope of the present disclosure concept in any way, but to illustrate the present disclosure concept to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0072] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The same reference numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present disclosure.
[0073] In one example, with the transformation of commercial banks, the use of big data is increasingly rich, especially for the application scenarios of querying, analyzing and utilizing historical data. In the prior art, when storing historical data, multiple historical databases are divided according to the data time range, and the historical data is stored, and each historical database is deployed in a separate server. When querying historical data, the server running the application connects all the historical databases, and after traversing all the databases to query the result data, the connection between the server and the historical databases is released, and the queried result data is loaded on the front end of the server and provided to the data user. However, in the prior art, since the connection between the server and the historical databases needs to be released after traversing all the databases to query the result data, if the speed of querying any historical database is fast, all the connections need to be released after all the historical databases are queried, which leads to more resources occupied by the query operation, and further leads to poor resource calling ability of the database connection.
[0074] The data source connection pool control method, device and server provided by the present application aim to solve the above technical problems of the prior art.
[0075] The technical solutions of the present application and how the technical solutions of the present application solve the above technical problems will be described in detail below with specific examples. The following specific examples can be combined with each other, and the same or similar concepts or processes can not be described again in some examples. The embodiments of the present application will be described below with reference to the drawings.
[0076] Figure 1 A flowchart of a data source connection pool control method provided by an embodiment of the present application is applied to middleware, which is installable software. As shown in the figure, Figure 1 The method comprises the following steps.
[0077] 101. Obtain the data source configuration information of the server through the middleware deployed in the server running the application, wherein the data source configuration information represents the configuration information of the data source connection pool of the server, and the configuration information includes the database connection strategy of the server.
[0078] Exemplarily, the execution subject of this embodiment is the server that deploys the middleware. Middleware is software that can be installed and uninstalled, and belongs to the category of reusable software. It is a general service located between the platform and the application. These services have standard program interfaces and protocols. For different operating systems and hardware platforms, there can be multiple implementations that comply with the interface and protocol specifications. During production deployment, as a middleware, it is independent of the server running the application, plug-and-play, highly scalable, flexible in application scenarios, and highly coupled. It has little impact on the architectural changes of the server running the application. In this way, the decoupling of application management and data source connection pool management is achieved. As follows Figure 2 As shown, Figure 2 A flow chart of another data source connection pool control method provided for an embodiment of the present application. Through the middleware deployed in the server running the application, the data source configuration information inside the server is automatically read, that is, the middleware automatically hosts the data source connection pool requirements of all data connection programs of the server, and can manage obtaining connections, releasing connections, and closing connection pools. Specifically, according to the physical address of the application, the data source connection pool is mapped accordingly, and the default configuration is set. These default configurations inherit the database connection configuration of the original application itself. At the same time, an automatic disconnection strategy is provided when the database connection pool management fails. For invalid database connections that have been loaded, you can choose to inherit the disconnection strategy of the original application itself, or you can choose the automatic disconnection strategy provided by the middleware. Among them, the data source configuration information represents the configuration information of the data source connection pool of the server running the application. The data source connection pool (DataSource Connection Pool) is used to store the configuration information of the database connection as an object in the memory of the server. The connection pool is responsible for allocating, managing and releasing database connections. The data source configuration information is used to determine the database connected to the server and obtain data from the database. Data source configuration information includes the driver, user information for determining the database connection address, the maximum number of database connections, the initial number of database connections, etc., as well as providing functions for obtaining connections, releasing connections, and closing the data source connection pool. User information includes user name and password.
[0079] For example, first create multiple data source configuration parent classes based on different types of database connection pools. After the middleware is deployed on the server running the application, the middleware automatically reads the server's internal data source configuration information. Based on each server's actual data source configuration information, the middleware's corresponding implementation class for the specific database source configuration type generates database connection information, which is the data source configuration information. A management class can also be implemented to manage multiple data source configuration implementation classes. This class can dynamically load new database information based on the connection log returned by the database and delete invalid database information that has already been loaded.
[0080] 102. In response to the editing operation on the database connection strategy, the database connection strategy of the server is determined as the middleware connection strategy, wherein the middleware connection strategy is used to release the connection between the server and the database according to the receiving time of the data received by the server from the database.
[0081] For example, the data source configuration information of the server includes an initial strategy, and the middleware includes the middleware connection strategy. The initial strategy refers to releasing the connection between each target database and the server after obtaining the target data from each target database connected to the server according to the received query instruction, that is, all target databases are released at the same time after obtaining the target data from all target databases. The middleware connection strategy refers to releasing the connection between any one target database and the server after obtaining the target data from any one target database connected to the server according to the received query instruction, that is, the connection is released first when the target data is obtained first, and the connection is released later when the target data is obtained later.
[0082] Therefore, after reading the data source configuration information of the server through the middleware, the initial strategy of the database connection strategy can be updated to the middleware connection strategy in response to the selection operation of the user on the database connection strategy. Alternatively, the initial strategy inside the server can be directly inherited as the database connection strategy of the server. In this scheme, the preferred scheme is to determine the middleware connection strategy as the database connection strategy of the server.
[0083] 103. In response to the query instruction, wherein the query instruction is used to instruct to query target data from a plurality of target databases, and the target data sent by each target database in the plurality of target databases is received.
[0084] For example, when the query instruction input by the user is received, the corresponding target database can be determined according to the query instruction, and the query instruction is sent to the target database. When the target database determines the target data according to the query instruction and sends it to the server, the server receives the target data sent by each target database in the plurality of target databases.
[0085] 104. Based on the middleware connection strategy, if it is determined that the target data sent by any one target database in the plurality of target databases has been obtained, the connection between the server and the target database is released according to the obtaining time of the target data.
[0086] Exemplarily, since the connection strategy of the server is the middleware connection strategy, if the middleware determines that the target data in any of the plurality of target databases has been acquired, the connection between any of the plurality of target databases and the server is released according to the acquisition time of the target data. Alternatively, if the connection strategy of the server is the initial connection strategy, the connection between each of the plurality of target databases and the server needs to be released respectively in a case where it is determined that the target data in each of the plurality of target databases has been acquired.
[0087] In the embodiment of the application, the middleware deployed in the server running the application is used to acquire the data source configuration information of the server. The data source configuration information represents the configuration information of the data source connection pool of the server, and the configuration information includes the database connection strategy of the server. In response to an editing operation on the database connection strategy, it is determined that the database connection strategy of the server is the middleware connection strategy. The middleware connection strategy is used to release the connection between the server and the database according to the receiving time of the data received by the server from the database. In response to a query instruction, the query instruction is used to instruct to query target data from a plurality of target databases, and the target data sent by each of the plurality of target databases is received. Based on the middleware connection strategy, if it is determined that the target data sent by any of the plurality of target databases has been acquired, the connection between any of the plurality of target databases and the server is released according to the acquisition time of the target data. In the scheme, the middleware deployed in the server running the application is used to acquire the data source configuration information of the server, it is determined that the database connection strategy of the server is the middleware connection strategy, then, according to the received query instruction, the query instruction is sent to the plurality of target databases, when the target database finds the target data corresponding to the query instruction and sends it to the server, the target data sent by each of the plurality of target databases is received by the server. Based on the middleware connection strategy, if it is determined that the target data in any of the plurality of target databases has been acquired, the connection between any of the plurality of target databases and the server is released immediately according to the acquisition time of the target data, that is, the release processing is performed according to the time of acquiring the target data, without waiting for the target information of all the target databases to be acquired before the release processing is performed. Therefore, the middleware can assist the server in managing the data source connection demand, the data source configuration information of the server is hosted using the middleware method when the application is deployed, and the program architecture in the server is decoupled by using the interface calling method. At the same time, through the application, the resource management of the data source connection pool can be optimized, the connection pool resources can be released dynamically through dynamic analysis, the efficiency of data connection is improved, the occupied resources are reduced, and the technical problem of poor resource calling ability of the database connection is solved.
[0088] Figure 3A flowchart of another data source connection pool control method provided by the embodiments of the present application is applied to a middleware, which is installable software. As shown in the figure, the method comprises the following steps. Figure 3
[0089] 201. Obtain data source configuration information of a server by running a middleware deployed in the server, wherein the data source configuration information represents configuration information of a data source connection pool of the server, and the configuration information comprises a database connection strategy of the server.
[0090] In one example, the data source configuration information comprises a connection address of the database, a maximum number of connections to the database, an initial number of connections to the database, and user information.
[0091] By way of example, this step can refer to step 101 in Figure 1 , and thus will not be described again.
[0092] 202. In response to an editing operation on the database connection strategy, update an initial strategy of the database connection strategy to a middleware connection strategy, wherein the middleware connection strategy is used to release a connection between the server and the database according to a receiving time of data received by the server from the database.
[0093] By way of example, this step can refer to step 102 in Figure 1 , and thus will not be described again.
[0094] 203. In response to a query instruction, wherein the query instruction comprises query condition information, determine a target database corresponding to the query condition information according to the data source configuration information, and send the query condition information to the target database, wherein the query condition information is used to query and obtain target data.
[0095] In one example, step 203 comprises: in response to a query instruction, wherein the query instruction comprises query condition information, determining a business module corresponding to the query condition information, wherein the business module is a pre-set module corresponding to a business type, each business module corresponds to different data source configuration information, determining the data source configuration information of the business module, determining a target database corresponding to the query condition information according to the data source configuration information of the business module, wherein the query condition information is used to query and obtain target data.
[0096] In one example, the method further comprises: if it is determined that the business module is a preset monitoring module, wherein the monitoring module is used to indicate that the server contains code information for monitoring, generating a data source connection configuration strategy for accessing the target database, wherein the data source connection configuration strategy comprises access step information of the target database, and the access step information comprises a query step corresponding to the query condition information and a monitoring step corresponding to the code information.
[0097] Exemplarily, a query instruction input by a user is received, wherein the query instruction includes query condition information, the target database corresponding to the query condition information is determined in the data source configuration information, and the query condition information is sent to the target database to query and obtain target data.
[0098] For example, after reading the data source configuration information of the server through the middleware, the edited data source configuration information corresponding to the business module can be obtained in response to the user's editing operation. Specifically, the business module corresponding to the business type can be obtained by editing according to the business module of the server, wherein the business module includes salary query, ordering and the like. The configuration information of the data source connection pool of each business module is obtained and maintained according to the configuration of the corresponding database of the business module. For example, the server distinguishes business modules, and the configuration requirements of each business module for multiple database connection pools are not the same. In this case, the specific database connection configuration class and database connection management class of the business module can be further subdivided on the basis of the database connection configuration class and database connection management class of the entire application level. Through this method, the server business module can configure different database connection strategies according to the different connection requirements of the data source connection pool, which refines the ability of data connection management, and at the same time, the database connection is managed in the middleware, realizing the decoupling of connection pool management and application program.
[0099] Further, for the program code of specific requirements, wherein the specific requirements are monitoring requirements, the monitoring module corresponding to the monitoring requirements needs to monitor the return log of the data source connection pool. The characteristics of the monitoring module are usually fast time requirements and complex traversal logic of the target database. The server can route to different data sources according to different query conditions through the middleware to provide data source connection configuration strategies. The data source connection configuration strategy includes database access step information, and the access step information includes query step corresponding to the query condition information and monitoring step corresponding to the code information. Therefore, the server can traverse the target database according to the access step and monitoring step in the data source connection configuration strategy in sequence, and thus can provide more personalized special requirements of the application for the connection pool, and empower and assist product requirements. For example, the access step information of the data source connection configuration strategy includes: the first step is to traverse target database 1 and target database 2, the second step is to traverse target data source data 3 and monitor the connection log returned by the target data source data 3, and the next step is the fourth step is to traverse target data source data 4.
[0100] Figure 4 Another flowchart of a data source connection pool control method provided by the embodiment of the application is shown in the following figure: Figure 4As shown, the refined database connection strategy is configured according to different configuration strategies. The specific application can correspond to different program codes according to the business module, and the program codes are recorded and configured according to the physical directory latitude in the middleware, so that the application can maintain different data source connection pools according to the configuration table; similarly, the application can also configure the database connection strategy according to the specific program code, and provide an optimized connection pool management approach for the scene with high data source connection pool management requirements.
[0101] In this step, in response to the query instruction input by the user, wherein the query instruction includes query condition information, the target database corresponding to the query condition information is determined according to the data source configuration information. If the business module has been configured in the data source configuration information, the business module corresponding to the query condition information is determined, and the target database is determined according to the business module corresponding to the query condition information.
[0102] 204, receiving the target data sent by the target database.
[0103] Exemplarily, when the server determines the target database according to the query instruction, all target databases are traversed to obtain the target data feedback by each target database, so that the target data sent by each target database can be received.
[0104] 205, receiving the connection log sent by the target database; wherein the connection log includes the acquisition time of the target data.
[0105] Exemplarily, when the database sends the target data to the server, the connection log is also sent to the server, and the connection log includes the acquisition time of the target data, the completion state and other information, so that the middleware can receive the connection log sent by each target database.
[0106] 206, if it is determined that the target data in any target database of the plurality of target databases has been acquired, the acquisition time of any target data is determined according to the connection log sent by any target database.
[0107] Exemplarily, if it is determined that the target data in any target database of the plurality of target databases has been acquired, the acquisition time of any target data can be determined according to the connection log sent by any target database.
[0108] 207, based on the middleware connection strategy and the acquisition time of any target data, the connection between the target database corresponding to any target data and the server is released.
[0109] Exemplarily, based on the middleware connection strategy and the acquisition time of any target data, the connection between any target database corresponding to the target data and the server is released, that is, after acquiring the target data sent by any target database, the connection between any target database and the server is disconnected immediately.
[0110] 208、If it is determined that the data source in the acquired configuration information is changed, the data source configuration information corresponding to the selection operation is obtained in response to the selection operation, wherein the selection operation includes any one or more of the following: adding a data source, deleting a data source, modifying a data source, and querying a data source.
[0111] Exemplarily, when it is determined that the data source side is changed, such as the change of the database division strategy of the data source or the change of the table division strategy, the configuration information of the server is re-read, and the information of the database connection pool of the data connection program in the middleware is updated, such as Figure 5 , Figure 5 The other data source connection pool control method provided by the embodiment of the present application provides a scene schematic diagram, which parses the connection demand business module through the middleware. For the case of data source side change, the application side does not need to care about the change of the data source side. For the case of adding a data source, after re-parsing the code, a configuration is added in the database side to realize the change of the demand. In this way, the code maintenance of the application side is reduced, and the configuration adjustment is made to the data source side, the maintenance is made to the data source, and the coupling configuration of the application side code is reduced.
[0112] In the embodiment of the application, the middleware deployed in the server running the application is used to obtain the data source configuration information of the server. The data source configuration information represents the configuration information of the data source connection pool of the server, and the configuration information includes the database connection strategy of the server. In response to an editing operation on the database connection strategy, the initial strategy of the database connection strategy is updated to a middleware connection strategy. The middleware connection strategy is used to release the connection between the server and the database according to the receiving time of the data received by the server from the database. In response to a query instruction, the query condition information corresponding to the target database is determined according to the data source configuration information, and the query condition information is sent to the target database. The query condition information is used to query and obtain the target data. The target data sent by the target database is received. The connection log sent by the target database is received. The connection log includes the acquisition time of the target data. If it is determined that the target data in any target database of the plurality of target databases has been acquired, the acquisition time of any target data is determined according to the connection log sent by any target database. Based on the middleware connection strategy and the acquisition time of any target data, the connection between the target database corresponding to any target data and the server is released. If it is determined that the data source in the configuration information has changed, the data source configuration information corresponding to the selection operation is obtained in response to the selection operation. The selection operation includes any one or more of the following: adding a data source, deleting a data source, modifying a data source, and querying a data source. Therefore, the middleware can assist the server in managing the data source connection requirement. In the application deployment, the middleware is used to host the data source configuration information of the server, and the interface calling method is used to decouple the program architecture in the server. At the same time, the application can optimize the resource management of the data source connection pool. Through dynamic analysis, the connection pool resources can be dynamically released, the efficiency of data connection is improved, the occupied resources are reduced, and the technical problem of poor resource calling ability of the database connection is solved. In addition, the server can also subdivide the database connection strategy according to the different requirements of each data source connection pool in the specific business module, and truly achieve fine management of the data source connection pool and high adhesion to the business scenario. Based on the encapsulation of the underlying database connection pool, a unified data source connection management capability is provided according to the actual connection of the data source. At the same time, for the special scene of the application, the configurable capability is provided for the program thread corresponding to the specific data source connection requirement, so as to realize the functions of platform empowerment, efficiency improvement, and product assistance.
[0113] Exemplarily, Figure 6 A flowchart of another data source connection pool control method provided by the embodiment of the application is shown in Figure 6As shown in the server dedicated data source connection configuration file, the data source required by the program is configured. When the program runs, it is necessary to ensure that all data sources are available at the same time. After waiting for the program results from all data sources, the results are stored in the memory of the server, and finally displayed on the page. In this running process, the technical solutions of the present application are described in detail below Figure 7 .
[0114] Exemplarily, Figure 7 The flowchart of another data source connection pool control method provided by the embodiment of the present application is shown in Figure 7 Step 301 represents that the middleware reads the data source configuration information of the server, step 302 represents the automatic disconnection strategy when the database connection pool management is invalid. For the invalid database connection that has been loaded, the original application internal disconnection strategy can be selected, or the automatic disconnection strategy provided by the middleware can be selected. Step 303 represents the database connection strategy configured in different business modules, and step 304 represents the modification of the data source configuration information when the database information of the data source changes.
[0115] Figure 8 The structural diagram of a data source connection pool control device provided by the embodiment of the present application is shown in Figure 8 The device comprises:
[0116] The acquisition unit 41 is configured to acquire the data source configuration information of the server through the middleware deployed in the server running the application. The data source configuration information represents the configuration information of the data source connection pool of the server, and the configuration information includes the database connection strategy of the server.
[0117] The determination unit 42 is configured to determine that the database connection strategy of the server is the middleware connection strategy in response to an editing operation on the database connection strategy. The middleware connection strategy is used to release the connection between the server and the database according to the receiving time of the data received by the server from the database.
[0118] The receiving unit 43 is configured to respond to a query instruction. The query instruction is used to instruct to query target data from a plurality of target databases, and receive the target data sent by each target database in the plurality of target databases.
[0119] The release unit 44 is configured to release the connection between any target database and the server according to the acquisition time of any target data based on the middleware connection strategy, if it is determined that the target data sent by any target database in the plurality of target databases has been acquired.
[0120] The device of this embodiment can execute the technical solution in the above method. Its specific implementation process and technical principles are the same and will not be repeated here.
[0121] Figure 9 A schematic diagram of another data source connection pool control device provided in an embodiment of the present application, wherein Figure 8 Based on the embodiment shown, Figure 9 As shown, the determining unit 42 is specifically configured to:
[0122] In response to an edit operation on the database connection policy, the initial policy of the database connection policy is updated to the middleware connection policy.
[0123] In one example, the receiving unit 43 includes:
[0124] The first determination module 431 is used to respond to a query instruction, wherein the query instruction includes query condition information, determine the target database corresponding to the query condition information according to the data source configuration information, and send the query condition information to the target database; wherein the query condition information is used to query and obtain target data.
[0125] The first receiving module 432 is configured to receive target data sent by a target database.
[0126] In one example, the first determining module 431 includes:
[0127] The first determination submodule 4311 is used to respond to a query instruction, wherein the query instruction includes query condition information, and determine the business module corresponding to the query condition information; wherein the business module is a pre-set module corresponding to the business type, and each business module corresponds to different data source configuration information; determine the data source configuration information of the business module.
[0128] The second determining submodule 4312 is used to determine the target database corresponding to the query condition information according to the data source configuration information of the business module; wherein the query condition information is used to query and obtain target data.
[0129] In one example, the apparatus further includes:
[0130] A generation unit 51 is configured to generate a data source connection configuration strategy for accessing a target database if it is determined that the business module is a preset monitoring module, wherein the monitoring module is configured to indicate that the server includes code information for monitoring; wherein the data source connection configuration strategy includes access step information of the target database, and the access step information includes a query step corresponding to the query condition information and a monitoring step corresponding to the code information.
[0131] In one example, the apparatus further includes:
[0132] The second receiving module 433 is configured to receive a connection log sent by the target database; the connection log comprises a target data acquisition time.
[0133] In one example, the releasing unit 44 comprises:
[0134] The second determining module 441 is configured to, if it is determined that the target data in any of the plurality of target databases has been acquired, determine the target data acquisition time according to the connection log sent by the any target database.
[0135] The releasing module 442 is configured to, based on the middleware connection strategy and the target data acquisition time, release the connection between the target database corresponding to the any target data and the server.
[0136] In one example, the configuration information of the data source connection pool further comprises a plurality of data sources; the apparatus further comprises:
[0137] The selecting unit 52 is configured to, if it is determined that the data source in the acquired configuration information has been changed, obtain data source configuration information corresponding to a selection operation in response to the selection operation; the selection operation comprises any one or more of the following:
[0138] Adding a data source, deleting a data source, modifying a data source, and querying a data source.
[0139] In one example, the data source configuration information comprises a connection address for a database, a maximum number of connections for the database, an initial number of connections for the database, and user information.
[0140] The apparatus of the present embodiment can execute the technical solutions in the above method, and the specific implementation process and technical principles are the same, which will not be repeated here.
[0141] Figure 10 A structural diagram of a server provided by the present embodiment is shown in FIG. 1. Figure 10 As shown in FIG. 1, the server comprises a memory 61 and a processor 62.
[0142] The memory 61 stores a computer program that can run on the processor 62.
[0143] The processor 62 is configured to execute the method provided by the above embodiments.
[0144] The server further comprises a receiver 63 and a transmitter 64. The receiver 63 is configured to receive instructions and data sent by an external device, and the transmitter 64 is configured to send instructions and data to the external device.
[0145] The embodiment of the present application further provides a non-transitory computer readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method provided by the above embodiment.
[0146] The embodiment of the present application further provides a computer program product, the computer program product comprises: a computer program, the computer program is stored in a readable storage medium, at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program so that the electronic device executes the scheme provided by any one of the above embodiments.
[0147] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the present disclosure cover any and all variations of the present disclosure that come within the scope of the following claims and their equivalents. It is intended that the specification and examples be considered exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0148] It should be understood that the present disclosure is not limited to the precise construction that has been described above and shown in the accompanying drawings, and that various modifications and changes can be made to the embodiments of the present disclosure without departing from the scope thereof. The scope of the present disclosure is limited only by the claims that follow.
Claims
1. A method of controlling a data source connection pool, characterized by, The method comprises: obtaining data source configuration information of a server by running middleware deployed in the server of the application; wherein the data source configuration information represents configuration information of a data source connection pool of the server, and the configuration information comprises a database connection strategy of the server; in response to an editing operation on the database connection strategy, determining that the database connection strategy of the server is a middleware connection strategy; wherein the middleware connection strategy is used to release a connection between the server and a database according to a receiving time of data received by the server from the database; in response to a query instruction, receiving target data sent by each target database in a plurality of target databases; wherein the query instruction is used to instruct querying target data from the plurality of target databases; based on the middleware connection strategy, if it is determined that target data sent by any target database in the plurality of target databases has been obtained, releasing a connection between the server and any target database according to an obtaining time of the target data.
2. The method of claim 1, wherein, The response to the editing operation on the database connection strategy to determine that the database connection strategy of the server is the middleware connection strategy comprises: in response to the editing operation on the database connection strategy, updating an initial strategy of the database connection strategy to the middleware connection strategy.
3. The method of claim 1, wherein, The response to the query instruction to receive target data sent by each target database in a plurality of target databases comprises: in response to the query instruction, determining a target database corresponding to query condition information according to the data source configuration information, and sending the query condition information to the target database; wherein the query condition information is used to query and obtain target data; receiving target data sent by the target database.
4. The method of claim 3, wherein, The response to the query instruction to determine a target database corresponding to query condition information according to the data source configuration information comprises: in response to the query instruction, determining a business module corresponding to the query condition information; wherein the business module is a pre-set module corresponding to a business type, each business module corresponds to different data source configuration information, and the data source configuration information of the business module is determined; determining a target database corresponding to the query condition information according to the data source configuration information of the business module; wherein the query condition information is used to query and obtain target data.
5. The method of claim 4, wherein, The method further comprises: if it is determined that the business module is a preset listening module, generating a data source connection configuration strategy for accessing the target database; wherein the data source connection configuration strategy comprises access step information of the target database, and the access step information comprises a query step corresponding to the query condition information and a listening step corresponding to the code information.
6. The method of claim 3, wherein, The method further comprises: receiving a connection log sent by the target database; wherein the connection log comprises an obtaining time of the target data.
7. The method of claim 6, wherein, The middleware connection strategy is used to release the connection between the server and any target database according to the acquisition time of any target data if it is determined that the target data sent by any target database in the plurality of target databases has been acquired. The acquisition time of any target data is determined according to the connection log sent by any target database if it is determined that the target data in any target database in the plurality of target databases has been acquired. The connection between the server and any target database corresponding to any target data is released based on the middleware connection strategy and the acquisition time of any target data.
8. The method of claim 1, wherein, The configuration information of the data source connection pool further includes a plurality of data sources; and the method further includes: If it is determined that the data source in the configuration information has been changed, the data source configuration information corresponding to the selection operation is obtained in response to a selection operation. The selection operation includes any one or more of the following: Adding a data source, deleting a data source, modifying a data source, and querying a data source.
9. The method according to any one of claims 1 to 8, characterized in that, The data source configuration information includes a connection address for a database, a maximum number of connections for a database, an initial number of connections for a database, and user information.
10. A data source connection pool control apparatus, characterized by comprising: The apparatus includes: An acquisition unit configured to acquire data source configuration information of a server by running middleware deployed in the server; wherein the data source configuration information represents configuration information of a data source connection pool of the server, and the configuration information includes a database connection strategy of the server; A determination unit configured to determine that the database connection strategy of the server is a middleware connection strategy in response to an editing operation on the database connection strategy; wherein the middleware connection strategy is used to release the connection between the server and a database according to the reception time of data received by the server from the database; A receiving unit configured to receive target data sent by each target database in a plurality of target databases in response to a query instruction; wherein the query instruction is used to instruct to query target data from the plurality of target databases; A release unit configured to release the connection between the server and any target database according to the acquisition time of any target data if it is determined that the target data sent by any target database in the plurality of target databases has been acquired based on the middleware connection strategy.
11. A server, characterized by The memory stores a computer program that can be run on the processor, and the processor implements the method of any one of claims 1-9 when executing the computer program.
12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the method of any one of claims 1-9.
13. A computer program product, characterised in that, The computer program is executed by the processor to implement the method of any one of claims 1-9.
Citation Information
Patent Citations
Heterogeneous database middleware access technique based on endowment insurance warning system
CN102110099A
Method and system for processing distributed transaction
CN106033437A