Connection management method and device of data source and computer program product
By dynamically managing the data connection pool and utilizing the idle connection and resource control mechanism, the problem of high resource consumption caused by managing different data sources with multiple connection pools is solved, efficient data source connection management is achieved, and system performance and user experience are improved.
Patent Information
- Application Number
- CN202510786417.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-12
- Publication Date
- 2025-09-16
AI Technical Summary
The existing technology uses multiple connection pools to manage data connections from different data sources, resulting in large resource consumption. Especially when the number of data sources is large and changes frequently, it increases system maintenance costs and resource usage, making it difficult to adapt to dynamic data source management needs.
By receiving the user's data source operation request, parsing the target data source and determining whether the target connection management object exists in the target connection pool, using the idle connection to establish a data connection, dynamically creating and clearing the connection management object, and combining the resource control mechanism, efficient management of multiple data sources is achieved.
It simplifies data connection and acquisition operations for multiple data sources, reduces resource consumption, improves system performance and user experience, simplifies operation and maintenance work, and reduces management costs.
Smart Images

Figure CN120653681A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of distributed systems, and more specifically, to a method, device, and computer program product for managing data source connections. Background Art
[0002] In a single business scenario, the data operations of a software system require access to tables from multiple different data sources. These data sources may include various types of databases, data warehouses, or other data storage systems, which are distributed in different locations on the network and have independent access control and operation permissions. Software system data source access is highly random. In environments such as automated testing platforms, data source configurations (such as accounts and passwords) change frequently due to testing requirements, environment settings, or security considerations. In addition, in database systems that are partitioned by date, the data sources that need to be accessed each day when the system is running are not fixed, which further increases the complexity of connection management.
[0003] Related technologies employ multiple connection pools to manage connections to different data sources, or temporarily create a connection and discard it after use. However, multiple dedicated connection pools require pre-configured information for all possible data sources. This static configuration model struggles with the dynamic addition, deletion, or update of data sources, particularly when the number of data sources is large and changes frequently, increasing system maintenance costs. When there are a large number of data sources, configuring a connection pool for each data source can lead to a large number of idle connections occupying system resources, potentially causing memory overflows or thread resource shortages. Furthermore, managing and maintaining the connection pools consumes additional computing resources, further exacerbating performance bottlenecks. Frequent changes in data source configurations require platform developers to manage and update them, increasing workload and reducing developer friendliness due to the opacity of data source switching. This is especially true in scenarios where multiple data sources are randomly accessed, requiring developers to constantly adapt and adjust, increasing management costs. When executing test cases on an automated testing platform, users of different applications need to randomly access different data sources. This randomness makes connection management even more difficult, especially when the number of data sources is large. Effectively and quickly allocating and reclaiming connections becomes a key challenge.
[0004] Currently, no effective solution has been proposed to the problem that the use of multiple connection pools to manage data connections from different data sources in related technologies leads to large resource consumption. Summary of the Invention
[0005] The main purpose of the present application is to provide a data source connection management method, device and computer program product to solve the problem of using multiple connection pools to manage data connections of different data sources in related technologies, resulting in large resource consumption.
[0006] To achieve the above-mentioned objectives, according to one aspect of the present application, a data source connection management method is provided. The method comprises: receiving a data source operation request from a user, parsing the data source operation request, obtaining a target data source to be accessed, and determining whether a target connection management object exists in a target connection pool, wherein the data source operation request is used to request an operation on data in the target data source, the target connection pool contains multiple connection management objects, each connection management object is used to manage a data connection of a data source, and the target connection management object is used to manage data connections of the target data source; if the target connection management object exists in the target connection pool, determining whether there is an idle connection in the connection list managed by the target connection management object; and if there is an idle connection in the connection list managed by the target connection management object, establishing a data connection between the user and the target data source based on the idle connection.
[0007] Optionally, after determining whether the target connection management object exists in the target connection pool, the method further includes: if the target connection management object does not exist in the target connection pool, establishing a new connection management object in the target connection pool for managing the data connection of the target data source; determining the total number of connections of all connection management objects in the target connection pool, and determining whether the total number of connections is greater than a total connection number threshold; if the total number of connections is less than or equal to the total connection number threshold, creating a new connection in the new connection management object, and establishing a data connection between the user and the target data source based on the new connection; if the total number of connections is greater than the total connection number threshold, issuing a prompt message, wherein the prompt message is used to indicate that the data connection is busy.
[0008] Optionally, after determining whether there is an idle connection in the connection list managed by the target connection management object, the method further includes: if there is no idle connection in the connection list managed by the target connection management object, determining the number of sub-connections in the connection list, and determining whether the number of sub-connections is greater than a sub-connection number threshold of the target connection management object, wherein the number of sub-connections is the number of all data connections managed by the target connection management object; if the number of sub-connections is greater than the sub-connection number threshold of the target connection management object, issuing a prompt message, wherein the prompt message is used to indicate that the data connection is busy; if the number of sub-connections is less than or equal to the sub-connection number threshold of the target connection management object, determining whether the total number of connections is greater than the total connection number threshold; if the total number of connections is less than or equal to the total connection number threshold, creating a new connection in the target connection management object, and establishing a data connection between the user and the target data source based on the new connection; if the total number of connections is greater than the total connection number threshold, issuing a prompt message.
[0009] Optionally, the method also includes: for each connection management object in the target connection pool, determining N data connections managed by the connection management object, where N is a positive integer; for each data connection, determining whether the data connection is a core connection, where a core connection is a data connection whose life cycle is greater than or equal to a preset life cycle threshold; if the data connection is a core connection, determining the first survival time of the core connection from the creation time to the current time at preset time intervals; if the first survival time is greater than or equal to the survival time threshold of the connection management object, clearing the core connection from the connection management object.
[0010] Optionally, after determining whether the data connection is a core connection, the method further includes: if the data connection is not a core connection, determining the idle time of the data connection at preset time intervals, wherein the idle time is the time between the last application of the data connection and the current time; if the idle time is greater than or equal to the idle time threshold managed by the connection management object, clearing the data connection from the connection management object; if the idle time is less than the idle time threshold managed by the connection management object, determining a second survival time of the data connection; if the second survival time is greater than or equal to the survival time threshold, clearing the data connection from the connection management object.
[0011] Optionally, after establishing a data connection between the user and the target data source based on the idle connection, the method further includes: determining the total number of connections of all connection management objects in the target connection pool, calculating the ratio of the total number of connections to the total connection number threshold, and judging whether the ratio is greater than or equal to the cleanup threshold; if the ratio is greater than or equal to the cleanup threshold, determining the idle duration of all idle connections in the target connection pool; for each idle connection, judging whether the idle duration of the idle connection is greater than or equal to the target duration threshold, wherein the target duration threshold is less than the idle duration threshold; if the idle duration of the idle connection is greater than or equal to the target duration threshold, clearing the idle connection from the target connection pool.
[0012] Optionally, the method also includes: for each connection management object in the target connection pool, after the connection management object creates a new connection, determining the target number of data connections managed by the connection management object; judging whether the target number is greater than or equal to the core connection number threshold of the connection management object; and if the target number is greater than or equal to the core connection number threshold of the connection management object, clearing the target data connection from the connection management object, wherein the target data connection is a data connection whose idle time is greater than or equal to the idle time threshold managed by the connection management object.
[0013] To achieve the above-mentioned objective, according to another aspect of the present application, a data source connection management device is provided. The device comprises: a receiving unit configured to receive a data source operation request from a user, parse the data source operation request, obtain a target data source to be accessed, and determine whether a target connection management object exists in a target connection pool, wherein the data source operation request is used to request an operation on data in the target data source, the target connection pool contains multiple connection management objects, each connection management object is used to manage a data connection of a data source, and the target connection management object is used to manage the data connection of the target data source; a determining unit configured to, if the target connection management object exists in the target connection pool, determine whether there is an idle connection in the connection list managed by the target connection management object; and a first establishing unit configured to, if an idle connection exists in the connection list managed by the target connection management object, establish a data connection between the user and the target data source based on the idle connection.
[0014] In an embodiment of the present application, a data source operation request from a user is received, the data source operation request is parsed, a target data source to be accessed is obtained, and it is determined whether a target connection management object exists in a target connection pool. The data source operation request is used to request an operation on data in the target data source. The target connection pool contains multiple connection management objects, each connection management object is used to manage a data connection of a data source, and the target connection management object is used to manage the data connection of the target data source. If a target connection management object exists in the target connection pool, it is determined whether there is an idle connection in the connection list managed by the target connection management object. If an idle connection exists in the connection list managed by the target connection management object, a data connection between the user and the target data source is established based on the idle connection. In this way, multiple connection management objects are managed by one target connection pool, and different connection management objects manage data connections of different data sources. This simplifies the data connection acquisition operation for multiple data sources and eliminates the need to pay attention to the management of multiple data source connections, thereby achieving the technical effect of reducing the resources used by data source connections, thereby solving the technical problem of using multiple connection pools to manage data connections of different data sources, resulting in large resource consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:
[0016] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for managing a connection of a data source is shown;
[0017] Figure 2This is a flow chart of a data source connection management method provided in accordance with an embodiment of the present application;
[0018] Figure 3 is a schematic diagram of a target connection pool provided according to an embodiment of the present application;
[0019] Figure 4 This is a schematic diagram of a target connection pool managing data connections according to an embodiment of the present application;
[0020] Figure 5 is a schematic diagram of a data connection establishment process provided in an embodiment of the present application;
[0021] Figure 6 is a schematic diagram of a data source connection management device provided according to an embodiment of the present application;
[0022] Figure 7 This is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] It should be noted that the collected information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for display, data for analysis, etc.) involved in this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation portals for users to choose to authorize or refuse. For example, an interface is set up between this system and relevant users or institutions to provide users with corresponding operation portals for users to choose to agree or refuse the automated decision-making results; if the user chooses to refuse, the expert decision-making process will be entered.
[0026] Example 1
[0027] According to an embodiment of the present application, a method embodiment for connection management of a data source is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0028] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG1 shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for managing the connection of a data source. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more (illustrated as 102a, 102b, ..., 102n in the figure) processors 102 (the processor 102 may include but is not limited to a processing device such as an MCU (Microcontroller Unit) or an FPGA (Field-Programmable Gate Array), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a USB (Universal Serial Bus) port (which may be included as one of the ports of a BUS (Business, bus)), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0029] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0030] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the data source connection management method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above-mentioned data source connection management method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0031] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0032] The display may be, for example, a touch screen liquid crystal display that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0033] In the above operating environment, this application provides a data source connection management method. Figure 2 This is a flow chart of a method for managing data source connections according to an embodiment of the present application. Figure 2 As shown, the method includes:
[0034] Step S201: Receive a data source operation request from the user, parse the data source operation request, obtain the target data source to be accessed, and determine whether a target connection management object exists in the target connection pool. The data source operation request is used to request an operation on the data in the target data source. The target connection pool contains multiple connection management objects, each connection management object is used to manage the data connection of a data source, and the target connection management object is used to manage the data connection of the target data source.
[0035] In step S201, in this embodiment, all data connections from different data sources are managed by the same DSP (DataSourcePool), also known as the target connection pool, supporting dynamic data source switching. Data sources can include different types of databases, and users are unaware of data source switching; they only need to interact with the DSP to obtain data connections. By maintaining a target connection pool, connections from multiple data sources are managed. Data connections belonging to the same data source are managed by the DS (DataSource object), also known as the connection management object. Figure 3 is a schematic diagram of a target connection pool provided according to an embodiment of the present application, such as Figure 3 As shown, in DSP, there can be multiple DSs (DS1, DS2, DS3, ..., DSn), representing connection management objects belonging to different data sources. Each connection management object manages multiple data connections (connection 1, connection 2, connection 3 and connection 4) belonging to the same data source.
[0036] For example, Figure 4 Schematic diagram of target connection pool management data connection according to an embodiment of the present application. Figure 4 As shown, Actor, that is, the user provides the data source information that needs to be accessed. DSP contains multiple connection management objects. Each connection management object manages multiple data connections of a data source. DSP is responsible for creating connections, reusing connections, and cleaning up connections.
[0037] DSP parameters include dsp_max_size: the total connection number threshold. The sum of all DS connection numbers must not be greater than this value, otherwise new connections cannot be created. dsp_clean_fast_threshold: the cleanup threshold, which can be set to about 75% of ds max size. Figure 3The dashed line in the figure represents this parameter. When the total number of connections in the DSP reaches this value, connection resources are becoming congested and idle connections need to be cleared as soon as possible, triggering the fast connection cleanup mechanism (cleaning connections whose idle time exceeds dsp_clean_fast_time). dsp_clean_fast_time: Target duration threshold. This value can be set lower than ds_idle_time. Connections in the DSP that have been idle for longer than this value are likely to eventually be idle for longer than ds_idle_time. Therefore, when the fast connection cleanup mechanism is triggered, such connections are cleared in advance to reduce the possibility of the number of connections reaching ds_max_size.
[0038] The parameters of each DS include ds_core_size: the core connection number threshold, which indicates the number of connections resident in a DS. The core connection has a longer life cycle and can avoid the creation of too many connections. ds_max_size: the sub-connection number threshold, which indicates the maximum number of connections in a DS. When the number of connections in a DS reaches this value, no new connections will be created for this data source. Prevent a data source from creating too many connections and squeezing out the connection resources of other data sources. ds_idle_time: idle time threshold. If the idle time of a data connection of a non-core connection is greater than this value, then this connection should be closed to prevent too many idle connections from occupying resources. ds_max_time: survival time threshold, which indicates the maximum life cycle of each data connection in the DS. If the creation time has exceeded this value now, this connection should be closed to prevent connection leakage. It should be noted that the DS parameters of different connection management objects can be different.
[0039] For each data source operation request from the user, the corresponding DS is first searched in the DSP. If there is an idle connection in the DS, the idle connection is returned. If there is no idle connection in the DS, it is determined whether the number of connections in the DS is greater than the sub-connection number threshold. If it is greater, no connection is returned. Otherwise, a new connection is created in the DS and returned.
[0040] Step S202: If the target connection management object exists in the target connection pool, it is determined whether there is an idle connection in the connection list managed by the target connection management object.
[0041] In step S202, if the target connection management object exists in the target connection pool, its connection list is accessed from the target connection management object. The connection list can be a data structure, such as a linked list, queue, or set, used to store and manage all active, idle, and abandoned data connections. Then, the data connections in the connection list are traversed (possibly random access if a set is used) to check their status. If at least one idle connection is found in the connection list, true is returned, indicating that an idle connection exists in the target connection management object and can be used. If no idle connection is found, false is returned, indicating that all data connections in the target connection management object are in use and no idle connection can be immediately provided.
[0042] Step S203: If there is an idle connection in the connection list managed by the target connection management object, a data connection is established between the user and the target data source based on the idle connection.
[0043] In step S203, if there are idle connections in the connection list managed by the target connection management object, a data connection is established between the user and the target data source based on these idle connections, and one connection is selected from the identified idle connections. The selection strategy may vary depending on the specific implementation. For example, you can select the connection that has been used least recently, randomly select an idle connection, or select the first idle connection found. After selecting an idle connection, you need to verify whether the connection is still valid. Even if a connection is marked as "idle" in the list, there is no guarantee that it will still work properly when it is attempted to be used. Verifying the validity of the connection can be achieved by executing a lightweight query (such as checking the existence of a table) or checking the timeout of the connection. If the connection is valid, it is sent to the user to establish a data connection.
[0044] The data source connection management method provided by the embodiment of the present application receives a data source operation request from a user, parses the data source operation request, obtains a target data source to be accessed, and determines whether a target connection management object exists in a target connection pool, wherein the data source operation request is used to request an operation on data in the target data source, the target connection pool contains multiple connection management objects, each connection management object is used to manage a data connection of a data source, and the target connection management object is used to manage the data connection of the target data source; if a target connection management object exists in the target connection pool, it is determined whether there is an idle connection in the connection list managed by the target connection management object; if there is an idle connection in the connection list managed by the target connection management object, a data connection between the user and the target data source is established based on the idle connection, thereby solving the problem of using multiple connection pools to manage data connections of different data sources in the related art, resulting in large resource consumption. By managing multiple connection management objects through one target connection pool, different connection management objects realize the management of data connections of different data sources, thereby simplifying the data connection acquisition operation of multiple data sources, eliminating the need to pay attention to the purpose of multiple data source connection management, thereby achieving the technical effect of reducing the resources used by data source connections, and further solving the technical problem of using multiple connection pools to manage data connections of different data sources, resulting in large resource consumption.
[0045] If there is no target connection management object in the target connection pool, a new connection management object needs to be created. Optionally, in the connection management method for the data source provided in the embodiment of the present application, after determining whether the target connection management object exists in the target connection pool, the method further includes: if the target connection management object does not exist in the target connection pool, establishing a new connection management object in the target connection pool for managing the data connection of the target data source; determining the total number of connections of all connection management objects in the target connection pool, and determining whether the total number of connections is greater than the total number of connections threshold; if the total number of connections is less than or equal to the total number of connections threshold, creating a new connection in the new connection management object, and establishing a data connection between the user and the target data source based on the new connection; if the total number of connections is greater than the total number of connections threshold, issuing a prompt message, wherein the prompt message is used to indicate that the data connection is busy.
[0046] In some embodiments, if there is no target connection management object in the target connection pool, a new connection management object needs to be created in the DSP to manage the data connection of the target data source. When creating the new connection management object, its configuration parameters, such as ds_core_size, ds_max_size, ds_idle_time, and ds_max_time, need to be initialized. To comply with the DSP's connection resource limits, it is necessary to count the total number of connections managed by all DS objects in the current DSP. A check is performed to see if the total number of connections exceeds a preset total connection threshold. If the total number of connections is less than or equal to the threshold, it indicates that there are resources available to create a new data connection. A new connection is created in the newly created new connection management object. After the new connection is created, it is sent to the user to establish a data connection between the user and the target data source. If the total number of connections exceeds the total connection threshold, it indicates that the DSP's connection resources are already limited and a new connection should not be created at this time. The DSP may send a prompt message to the user to inform them that the current data connection is busy and a new connection cannot be provided immediately.
[0047] This embodiment significantly improves the management efficiency and system performance of database connections in multi-data source random access scenarios by dynamically creating connection management objects, intelligently controlling the total number of connections, and providing timely feedback on resource status. It also simplifies operation and maintenance work and improves user experience.
[0048] If the target connection management object does not have an idle connection, a new connection needs to be created in the target connection management object. Optionally, in the connection management method for the data source provided in the embodiment of the present application, after determining whether there is an idle connection in the connection list managed by the target connection management object, the method further includes: if there is no idle connection in the connection list managed by the target connection management object, determining the number of sub-connections in the connection list, and determining whether the number of sub-connections is greater than a sub-connection number threshold of the target connection management object, wherein the number of sub-connections is the number of all data connections managed by the target connection management object; if the number of sub-connections is greater than the sub-connection number threshold of the target connection management object, issuing a prompt message, wherein the prompt message is used to prompt that the data connection is busy; if the number of sub-connections is less than or equal to the sub-connection number threshold of the target connection management object, determining whether the total number of connections is greater than the total connection number threshold; if the total number of connections is less than or equal to the total connection number threshold, creating a new connection in the target connection management object, and establishing a data connection between the user and the target data source based on the new connection; if the total number of connections is greater than the total connection number threshold, issuing a prompt message.
[0049] In some embodiments, if the target connection management object has no idle connections, the number of all data connections currently managed by the target connection management object, that is, the number of sub-connections, is obtained. A check is performed to determine whether the current number of sub-connections exceeds the sub-connection number threshold configured for the target connection management object. If so, the target connection management object has reached its maximum number of connections and cannot create more connections. A prompt message is issued to inform the user or application that the current data connection is busy and a new connection cannot be provided immediately. If the number of sub-connections does not exceed its sub-connection number threshold, it is also necessary to check whether the total number of connections managed by all DS objects in the entire DSP exceeds the DSP's total connection number threshold.
[0050] If the total number of connections is less than or equal to the total connection threshold, the DSP has available resources and can therefore create a new connection in the target connection management object. After the new connection is created, it is returned to the user or application, enabling it to establish a data connection with the target data source. If the total number of connections exceeds the total connection threshold, even if the number of sub-connections in the current target connection management object does not exceed the sub-connection threshold, the DSP must issue a warning message, indicating that overall connection resources are insufficient and that no new connections can be created.
[0051] This embodiment implements resource control at both the single DS and DSP levels, combining a busy connection prompt mechanism with the ability to dynamically create connections. This achieves efficient and fair management and allocation of database connection resources in random access scenarios with multiple data sources, while improving user experience and system operation and maintenance efficiency and reducing maintenance costs.
[0052] Each connection management object is provided with a core connection with a longer life cycle. Optionally, in the connection management method for a data source provided in an embodiment of the present application, the method further includes: for each connection management object in the target connection pool, determining N data connections managed by the connection management object, where N is a positive integer; for each data connection, determining whether the data connection is a core connection, where a core connection is a data connection with a life cycle greater than or equal to a preset life cycle threshold; if the data connection is a core connection, determining the first survival time of the core connection from the creation time to the current time at preset time intervals; and if the first survival time is greater than or equal to the survival time threshold of the connection management object, clearing the core connection from the connection management object.
[0053] In some embodiments, for each DS object in the DSP, the connection list of the DS object is traversed to determine core connections and ordinary data connections. For core connections, the current status of all core connections is checked at a preset interval (for example, every minute or every 30 seconds), that is, the first survival time from the creation time to the current time. Core connections whose first survival time is greater than or equal to the survival time threshold need to be cleared from the DS object. In other words, the connection is closed and removed from the connection list of the DS object to free up system resources.
[0054] This embodiment effectively balances the relationship between efficient resource utilization and service stability by dynamically managing the life cycle of core connections, and realizes self-purification and health management of the connection pool through automated means, significantly improving system performance and user experience while reducing operation and maintenance costs.
[0055] For non-core connections, the data connection needs to be cleaned up through the idle time threshold. Optionally, in the connection management method of the data source provided in the embodiment of the present application, after determining whether the data connection is a core connection, the method also includes: if the data connection is not a core connection, determining the idle time of the data connection at preset time intervals, wherein the idle time is the time between the last application of the data connection and the current time; if the idle time is greater than or equal to the idle time threshold managed by the connection management object, cleaning up the data connection from the connection management object; if the idle time is less than the idle time threshold managed by the connection management object, determining a second survival time of the data connection; if the second survival time is greater than or equal to the survival time threshold, cleaning up the data connection from the connection management object.
[0056] In some embodiments, for non-core connections, the DS object periodically (for example, every minute) checks the idle duration of each data connection, that is, the duration from the last time it was applied to the current time. If the idle duration of the non-core connection is equal to or greater than the idle duration threshold configured by the DS object, the data connection needs to be cleared, and connections with too long idle time will waste resources. If the idle duration of the non-core connection is less than the idle duration threshold, then it is necessary to further check its second survival duration. If the second survival duration of the non-core connection is greater than or equal to the survival duration threshold, the connection also needs to be cleared to prevent resource leakage problems that may be caused by connections that have not been closed for a long time.
[0057] This embodiment improves resource utilization efficiency, enhances system stability, optimizes performance, controls operating costs, simplifies operation and maintenance management, and ultimately enhances user experience by intelligently managing the lifecycle of non-core data connections.
[0058] In order to avoid excessive congestion of data connections in the target connection pool, data connections are cleaned up based on a cleanup threshold and a target duration threshold. Optionally, in the connection management method for a data source provided in an embodiment of the present application, after establishing a data connection between a user and a target data source based on an idle connection, the method further includes: determining the total number of connections of all connection management objects in the target connection pool, calculating the ratio of the total number of connections to the total number of connections threshold, and judging whether the ratio is greater than or equal to the cleanup threshold; if the ratio is greater than or equal to the cleanup threshold, determining the idle duration of all idle connections in the target connection pool; for each idle connection, judging whether the idle duration of the idle connection is greater than or equal to the target duration threshold, wherein the target duration threshold is less than the idle duration threshold; if the idle duration of the idle connection is greater than or equal to the target duration threshold, clearing the idle connection from the target connection pool.
[0059] In some embodiments, the target connection pool employs a fast cleanup mechanism: DSP objects manage overall connections to ensure connection resource availability. When the total number of connections reaches a threshold, new connections are rejected. When the ratio of the total number of connections to the threshold exceeds a cleanup threshold, the fast cleanup mechanism is triggered: data connections in each connection management object that have been idle for longer than a target duration threshold are closed and cleaned up.
[0060] This embodiment effectively optimizes resource utilization, maintains the health of the connection pool, improves system performance and user experience, and simplifies operation and maintenance management by introducing a connection pool resource early warning and rapid cleanup mechanism.
[0061] Each connection management object periodically cleans up data connections based on a core connection number threshold. Optionally, in the connection management method for a data source provided in an embodiment of the present application, the method further includes: for each connection management object in a target connection pool, after the connection management object creates a new connection, determining a target number of data connections managed by the connection management object; judging whether the target number is greater than or equal to a core connection number threshold of the connection management object; and if the target number is greater than or equal to the core connection number threshold of the connection management object, cleaning up target data connections from the connection management object, wherein the target data connection is a data connection whose idle time is greater than or equal to the idle time threshold managed by the connection management object.
[0062] In some embodiments, each connection management object in the target connection pool utilizes a regular cleanup mechanism: For each connection in a DS, its idle time (the idle time is reset to zero after the connection is used) and the connection lifetime are recorded. When the target number of DSs exceeds the core connection number threshold, data connections in the DS that have been idle for longer than the idle duration threshold are closed until the number of connections reaches the core connection number threshold.
[0063] This embodiment achieves efficient resource utilization and healthy maintenance of the connection pool by dynamically monitoring and adjusting the number of connections in the connection pool, combined with a conventional cleanup mechanism, thereby improving the system's responsiveness and stability, optimizing the user experience, and reducing operation and maintenance costs.
[0064] According to another embodiment of the present application, a data connection establishment process is also provided. Figure 5 is a schematic diagram of a data connection establishment process provided in an embodiment of the present application, such as Figure 5 As shown, a database operation request is received and it is determined whether a DS corresponding to the data source exists in the DSP. If not, a DS object is created in the DSP and it is determined whether the total number of connections in the DSP is greater than dsp_max_size. If so, a busy exception is prompted. If the total number of connections is less than or equal to dsp_max_size, a new connection is created in the DS and the idle new connection is returned. If a DS corresponding to the data source exists in the DSP, it is determined whether there is an idle connection in the DS. If there is an idle connection, the data connection is returned to the user. If there is no idle connection, it is determined whether the number of connections in the DS is greater than dsmax size. If so, a busy exception is prompted. If it is less than or equal to ds_max_size, it is determined whether the total number of connections in the DSP is greater than dsp_max_size. If so, a busy exception is prompted. If the total number of connections is less than or equal to dsp_max_size, a new connection is created in the DS and the idle new connection is returned.
[0065] The data connection establishment process of this embodiment achieves efficient resource utilization, improved user experience, simplified operation and maintenance work, and guaranteed business continuity through dynamic judgment and intelligent management of database connections.
[0066] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0067] Example 2
[0068] The present application also provides a data source connection management device. It should be noted that the data source connection management device of the present application embodiment can be used to execute the data source connection management method provided in the present application embodiment. The following describes the data source connection management device provided in the present application embodiment.
[0069] According to an embodiment of the present application, a device for implementing the above-mentioned data source connection management method is also provided. Figure 6 Schematic diagram of a data source connection management device according to an embodiment of the present application. Figure 6As shown, the device includes:
[0070] Receiving unit 601 is used to receive a user's data source operation request, parse the data source operation request, obtain the target data source to be accessed, and determine whether a target connection management object exists in the target connection pool. The data source operation request is used to request an operation on data in the target data source. The target connection pool contains multiple connection management objects, each connection management object is used to manage the data connection of a data source, and the target connection management object is used to manage the data connection of the target data source.
[0071] The judging unit 602 is configured to, when a target connection management object exists in the target connection pool, judge whether there is an idle connection in the connection list managed by the target connection management object.
[0072] The first establishing unit 603 is configured to establish a data connection between the user and the target data source based on an idle connection when there is an idle connection in the connection list managed by the target connection management object.
[0073] The data source connection management device provided in an embodiment of the present application includes a receiving unit 601 that receives a data source operation request from a user, parses the data source operation request, obtains a target data source to be accessed, and determines whether a target connection management object exists in a target connection pool. The data source operation request is used to request an operation on data in the target data source. The target connection pool contains multiple connection management objects, each of which is used to manage a data connection of a data source, and the target connection management object is used to manage the data connection of the target data source. The determining unit 602 determines whether there is an idle connection in the connection list managed by the target connection management object if the target connection management object exists in the target connection pool. The first establishing unit 603 establishes a data connection between the user and the target data source based on the idle connection if there is an idle connection in the connection list managed by the target connection management object. The multiple connection management objects are managed by one target connection pool, and different connection management objects manage data connections of different data sources. This simplifies the data connection acquisition operation for multiple data sources and eliminates the need to pay attention to the management of multiple data source connections, thereby achieving the technical effect of reducing the resources used by data source connections and solving the technical problem of using multiple connection pools to manage data connections of different data sources, which leads to large resource consumption.
[0074] Optionally, in the connection management device for the data source provided in the embodiment of the present application, the device also includes: a second establishing unit, used to establish a new connection management object in the target connection pool for managing the data connection of the target data source when the target connection management object does not exist in the target connection pool; a first determining unit, used to determine the total number of connections of all connection management objects in the target connection pool, and to determine whether the total number of connections is greater than a total connection number threshold; a first creating unit, used to create a new connection in the new connection management object when the total number of connections is less than or equal to the total connection number threshold, and establish a data connection between the user and the target data source based on the new connection; a first prompting unit, used to issue a prompting message when the total number of connections is greater than the total connection number threshold, wherein the prompting message is used to prompt that the data connection is busy.
[0075] Optionally, in the connection management device for a data source provided in an embodiment of the present application, the device further includes: a second determination unit, for determining the number of sub-connections in the connection list managed by the target connection management object when there are no idle connections, and determining whether the number of sub-connections is greater than the sub-connection number threshold of the target connection management object, wherein the number of sub-connections is the number of all data connections managed by the target connection management object; a second prompt unit, for issuing a prompt message when the number of sub-connections is greater than the sub-connection number threshold of the target connection management object, wherein the prompt message is used to indicate that the data connection is busy; a quantity judgment unit, for determining whether the total number of connections is greater than the total connection number threshold when the number of sub-connections is less than or equal to the sub-connection number threshold of the target connection management object; a second creation unit, for creating a new connection in the target connection management object when the total number of connections is less than or equal to the total connection number threshold, and establishing a data connection between the user and the target data source based on the new connection; a third prompt unit, for issuing a prompt message when the total number of connections is greater than the total connection number threshold.
[0076] Optionally, in the connection management device of the data source provided in the embodiment of the present application, the device also includes: a third determination unit, used to determine, for each connection management object in the target connection pool, N data connections managed by the connection management object, where N is a positive integer; a core connection judgment unit, used to determine, for each data connection, whether the data connection is a core connection, where a core connection is a data connection whose life cycle is greater than or equal to a preset life cycle threshold; a fourth determination unit, used to determine, when the data connection is a core connection, the first survival time of the core connection from the creation time to the current time at preset time intervals; a first cleaning unit, used to clean up the core connection from the connection management object when the first survival time is greater than or equal to the survival time threshold of the connection management object.
[0077] Optionally, in the connection management device of the data source provided in the embodiment of the present application, the device also includes: a fifth determination unit, for determining the idle time of the data connection at preset time intervals when the data connection is not a core connection, wherein the idle time is the time between the last application of the data connection and the current time; a second cleaning unit, for cleaning the data connection from the connection management object when the idle time is greater than or equal to the idle time threshold managed by the connection management object; a sixth determination unit, for determining the second survival time of the data connection when the idle time is less than the idle time threshold managed by the connection management object; and a third cleaning unit, for cleaning the data connection from the connection management object when the second survival time is greater than or equal to the survival time threshold.
[0078] Optionally, in the connection management device of the data source provided in the embodiment of the present application, the device also includes: a seventh determination unit, used to determine the total number of connections of all connection management objects in the target connection pool, calculate the ratio of the total number of connections to the total connection number threshold, and judge whether the ratio is greater than or equal to the cleanup threshold; an eighth determination unit, used to determine the idle time of all idle connections in the target connection pool when the ratio is greater than or equal to the cleanup threshold; a time judgment unit, used to judge for each idle connection whether the idle time of the idle connection is greater than or equal to the target time threshold, wherein the target time threshold is less than the idle time threshold; a fourth cleanup unit, used to clean up the idle connection from the target connection pool when the idle time of the idle connection is greater than or equal to the target time threshold.
[0079] Optionally, in the connection management device of the data source provided in the embodiment of the present application, the device also includes: a ninth determination unit, for determining, for each connection management object in the target connection pool, the target number of data connections managed by the connection management object after the connection management object creates a new connection; a quantity judgment unit, for judging whether the target number is greater than or equal to the core connection number threshold of the connection management object; and a fifth cleaning unit, for cleaning the target data connection from the connection management object when the target number is greater than or equal to the core connection number threshold of the connection management object, wherein the target data connection is a data connection whose idle time is greater than or equal to the idle time threshold managed by the connection management object.
[0080] It should be noted that the receiving unit 601, the judging unit 602, and the first establishing unit 603 correspond to steps S201 to S203 in Example 1. The three units and the corresponding steps implement the same examples and application scenarios, but are not limited to the contents disclosed in the above-mentioned Example 1. It should be noted that the above-mentioned modules or units can be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n). The above-mentioned modules or units can also be part of the device and can be run in the computer terminal 10 provided in Example 1.
[0081] Example 3
[0082] An embodiment of the present application may provide an electronic device, Figure 7 This is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 7 As shown, the electronic device may include: one or more ( Figure 7 Only one is shown) processor 702, memory 704, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0083] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the above-mentioned method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0084] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: receiving a user's data source operation request, parsing the data source operation request, obtaining the target data source to be accessed, and determining whether a target connection management object exists in the target connection pool, wherein the data source operation request is used to request an operation on the data in the target data source, the target connection pool contains multiple connection management objects, each connection management object is used to manage the data connection of a data source, and the target connection management object is used to manage the data connection of the target data source; if the target connection management object exists in the target connection pool, determining whether there is an idle connection in the connection list managed by the target connection management object; if there is an idle connection in the connection list managed by the target connection management object, establishing a data connection between the user and the target data source based on the idle connection.
[0085] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: if the target connection management object does not exist in the target connection pool, establish a new connection management object in the target connection pool for managing the data connection of the target data source; determine the total number of connections of all connection management objects in the target connection pool, and determine whether the total number of connections is greater than the total connection number threshold; if the total number of connections is less than or equal to the total connection number threshold, create a new connection in the new connection management object, and establish a data connection between the user and the target data source based on the new connection; if the total number of connections is greater than the total connection number threshold, issue a prompt message, wherein the prompt message is used to indicate that the data connection is busy.
[0086] The processor can also call information and applications stored in the memory through the transmission device to perform the following steps: when there is no idle connection in the connection list managed by the target connection management object, determine the number of sub-connections in the connection list, and judge whether the number of sub-connections is greater than the sub-connection number threshold of the target connection management object, wherein the number of sub-connections is the number of all data connections managed by the target connection management object; when the number of sub-connections is greater than the sub-connection number threshold of the target connection management object, issue a prompt message, wherein the prompt message is used to indicate that the data connection is busy; when the number of sub-connections is less than or equal to the sub-connection number threshold of the target connection management object, determine whether the total number of connections is greater than the total connection number threshold; when the total number of connections is less than or equal to the total connection number threshold, create a new connection in the target connection management object, and establish a data connection between the user and the target data source based on the new connection; when the total number of connections is greater than the total connection number threshold, issue a prompt message.
[0087] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: for each connection management object in the target connection pool, determine the N data connections managed by the connection management object, where N is a positive integer; for each data connection, determine whether the data connection is a core connection, where a core connection is a data connection with a life cycle greater than or equal to a preset life cycle threshold; if the data connection is a core connection, determine the first survival time of the core connection from the creation time to the current time at preset time intervals; if the first survival time is greater than or equal to the survival time threshold of the connection management object, clear the core connection from the connection management object.
[0088] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: when the data connection is not a core connection, determine the idle time of the data connection at preset time intervals, wherein the idle time is the time between the last application of the data connection and the current time; when the idle time is greater than or equal to the idle time threshold managed by the connection management object, clear the data connection from the connection management object; when the idle time is less than the idle time threshold managed by the connection management object, determine the second survival time of the data connection; when the second survival time is greater than or equal to the survival time threshold, clear the data connection from the connection management object.
[0089] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: determine the total number of connections of all connection management objects in the target connection pool, calculate the ratio of the total number of connections to the total connection number threshold, and determine whether the ratio is greater than or equal to the cleanup threshold; when the ratio is greater than or equal to the cleanup threshold, determine the idle time of all idle connections in the target connection pool; for each idle connection, determine whether the idle time of the idle connection is greater than or equal to the target time threshold, wherein the target time threshold is less than the idle time threshold; when the idle time of the idle connection is greater than or equal to the target time threshold, clean up the idle connection from the target connection pool.
[0090] The processor can also call the information and application stored in the memory through the transmission device to perform the following steps: for each connection management object in the target connection pool, after the connection management object creates a new connection, determine the target number of data connections managed by the connection management object; determine whether the target number is greater than or equal to the core connection number threshold of the connection management object; if the target number is greater than or equal to the core connection number threshold of the connection management object, clear the target data connection from the connection management object, wherein the target data connection is a data connection whose idle time is greater than or equal to the idle time threshold managed by the connection management object.
[0091] According to an embodiment of the present application, a method is provided for receiving a user's data source operation request, parsing the data source operation request, obtaining a target data source to be accessed, and determining whether a target connection management object exists in a target connection pool, wherein the data source operation request is used to request an operation on data in the target data source, the target connection pool contains multiple connection management objects, each connection management object is used to manage a data connection of a data source, and the target connection management object is used to manage the data connection of the target data source; if a target connection management object exists in the target connection pool, it is determined whether there is an idle connection in the connection list managed by the target connection management object; if an idle connection exists in the connection list managed by the target connection management object, a solution is provided for establishing a data connection between the user and the target data source based on the idle connection. By managing multiple connection management objects through one target connection pool, different connection management objects implement the management of data connections of different data sources, thereby achieving the purpose of simplifying the data connection acquisition operation of multiple data sources without having to pay attention to the management of multiple data source connections, thereby achieving the technical effect of reducing the resources used by data source connections, and thus solving the technical problem of using multiple connection pools to manage data connections of different data sources, resulting in large resource consumption.
[0092] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only, and the electronic device may also be a terminal device such as a smart phone, a tablet computer, a PDA, a mobile Internet device (MID), or a PAD. Figure 7 It does not limit the structure of the above electronic device. For example, the electronic device may also include Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or with Figure 7 Different configurations shown.
[0093] A person skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0094] Example 4
[0095] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the data source connection management method provided in the first embodiment.
[0096] Optionally, in this embodiment, the storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0097] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the steps of the method for managing connections to a data source.
[0098] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0099] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0100] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0101] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0102] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0103] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0104] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A data source connection management method, characterized in that: include: Receiving a data source operation request from a user, parsing the data source operation request, obtaining a target data source to be accessed, and determining whether a target connection management object exists in a target connection pool, wherein the data source operation request is used to request an operation on data in the target data source, the target connection pool contains multiple connection management objects, each connection management object is used to manage a data connection of a data source, and the target connection management object is used to manage the data connection of the target data source; If the target connection management object exists in the target connection pool, determining whether there is an idle connection in the connection list managed by the target connection management object; In a case where the idle connection exists in the connection list managed by the target connection management object, a data connection is established between the user and the target data source based on the idle connection.
2. The method according to claim 1, characterized in that After determining whether the target connection management object exists in the target connection pool, the method further includes: When the target connection management object does not exist in the target connection pool, establishing a new connection management object in the target connection pool for managing the data connection of the target data source; Determine the total number of connections of all connection management objects in the target connection pool, and determine whether the total number of connections is greater than a total connection number threshold; When the total number of connections is less than or equal to the total connection number threshold, creating a new connection in the new connection management object, and establishing a data connection between the user and the target data source based on the new connection; When the total number of connections is greater than the total connection number threshold, a prompt message is issued, wherein the prompt message is used to prompt that the data connection is busy.
3. The method according to claim 1, characterized in that After determining whether there is an idle connection in the connection list managed by the target connection management object, the method further includes: If the idle connection does not exist in the connection list managed by the target connection management object, determining the number of sub-connections in the connection list, and judging whether the number of sub-connections is greater than a sub-connection number threshold of the target connection management object, wherein the number of sub-connections is the number of all data connections managed by the target connection management object; When the number of sub-connections is greater than a sub-connection number threshold of the target connection management object, issuing a prompt message, wherein the prompt message is used to prompt that the data connection is busy; If the number of sub-connections is less than or equal to the sub-connection number threshold of the target connection management object, determining whether the total number of connections is greater than the total number of connections threshold; When the total number of connections is less than or equal to the total connection number threshold, creating a new connection in the target connection management object, and establishing a data connection between the user and the target data source based on the new connection; When the total number of connections is greater than the total connection number threshold, the prompt information is issued.
4. The method according to claim 1, wherein The method further comprises: For each connection management object in the target connection pool, determining N data connections managed by the connection management object, where N is a positive integer; For each data connection, determining whether the data connection is a core connection, wherein the core connection is a data connection whose life cycle is greater than or equal to a preset life cycle threshold; In a case where the data connection is the core connection, determining a first survival time of the core connection from a creation time to a current time at every preset time; When the first survival time is greater than or equal to a survival time threshold of the connection management object, the core connection is cleared from the connection management object.
5. The method according to claim 4, characterized in that After determining whether the data connection is a core connection, the method further includes: In the case that the data connection is not the core connection, determining the idle duration of the data connection every preset duration, wherein the idle duration is the duration between the last application of the data connection and the current time; When the idle time is greater than or equal to an idle time threshold managed by the connection management object, clearing the data connection from the connection management object; When the idle time is less than an idle time threshold managed by the connection management object, determining a second survival time of the data connection; When the second survival time is greater than or equal to the survival time threshold, the data connection is cleared from the connection management object.
6. The method according to claim 1, characterized in that After establishing a data connection between the user and the target data source based on the idle connection, the method further includes: Determine the total number of connections of all connection management objects in the target connection pool, calculate the ratio of the total number of connections to a total connection number threshold, and determine whether the ratio is greater than or equal to a cleanup threshold; When the ratio is greater than or equal to the cleaning threshold, determining the idle time of all idle connections in the target connection pool; For each idle connection, determining whether the idle duration of the idle connection is greater than or equal to a target duration threshold, wherein the target duration threshold is less than the idle duration threshold; When the idle time duration of the idle connection is greater than or equal to the target time duration threshold, the idle connection is cleared from the target connection pool.
7. The method according to claim 1, characterized in that The method further comprises: For each connection management object in the target connection pool, after the connection management object creates a new connection, determining a target number of data connections managed by the connection management object; Determining whether the target number is greater than or equal to a core connection number threshold of the connection management object; When the target number is greater than or equal to the core connection number threshold of the connection management object, clear the target data connection from the connection management object, wherein the target data connection is a data connection whose idle time is greater than or equal to the idle time threshold managed by the connection management object.
8. A data source connection management device, characterized in that: include: a receiving unit, configured to receive a data source operation request from a user, parse the data source operation request, obtain a target data source to be accessed, and determine whether a target connection management object exists in a target connection pool, wherein the data source operation request is used to request an operation on data in the target data source, the target connection pool contains multiple connection management objects, each connection management object is used to manage a data connection of a data source, and the target connection management object is used to manage the data connection of the target data source; a judging unit, configured to, when the target connection management object exists in the target connection pool, judge whether there is an idle connection in the connection list managed by the target connection management object; The first establishing unit is configured to establish a data connection between the user and the target data source based on the idle connection if the idle connection exists in the connection list managed by the target connection management object.
9. An electronic device, characterized in that: include: a memory storing an executable program; A processor is configured to run the program, wherein the program, when running, executes the data source connection management method according to any one of claims 1 to 7.
10. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the steps of the data source connection management method according to any one of claims 1 to 7 are implemented.