Database connection management method and device

By introducing preset connection parameter thresholds and token mechanisms in database connection management, the problem of excessive database connections caused by concurrent operations on multiple clients is solved, and the optimization management and priority control of database connections is realized, and the system is improved. Availability and reliability.

CN113220767BActive Publication Date: 2024-12-06INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110589787.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-28
Publication Date
2024-12-06
Estimated Expiration
2041-05-28

AI Technical Summary

Technical Problem

When multiple clients operate databases concurrently, the lack of connection management leads to excessive database connections, causing database downtime and application interruption. The lack of unified database connection resource management can easily lead to exhaustion of connection pool resources and affect the system Availability.

Method used

By receiving the client's database connection request, and determining whether to accept the connection request based on the preset connection parameter threshold (maximum connection threshold and preset priority application connection threshold), generating a token and recording the connection time, realizing the management and priority of database connections Level control ensures priority passage of important connections.

Benefits of technology

It effectively controls the number of connections initiated by the client, avoids service downtime caused by tight connection resources, improves the availability and reliability of the system, and ensures the availability of major services under high load conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113220767B_ABST
    Figure CN113220767B_ABST
Patent Text Reader

Abstract

This invention provides a database connection management method and apparatus, relating to the financial field. The method includes: receiving a database connection request from a client; determining whether to accept the connection request based on a preset connection parameter threshold; and allowing the client to connect to the database if the connection request is accepted. This invention's server connection management service can control the number of connection requests initiated by clients based on preset connection parameter thresholds, and can prioritize high-priority connections when connection resources are scarce. This effectively solves the service downtime problem caused by uncontrollable connection numbers, and the prioritization of primary connections improves system availability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to data processing technology, in particular to a database connection management method and device. Background Art

[0002] For client software, there are many data operations that require operating the database. For example, Delphi uses the DataSet control to connect to the database. Since the operations on the database are completely handled by the client, the number of database connections is proportional to the number of clients.

[0003] If there is no connection management measure when the client directly connects to the database, then when there are multiple clients and the same client operates the database concurrently, the excessive number of instantaneous connections will cause problems such as database downtime and application freezing. At the same time, each time the client interacts with the database, a new database connection is created each time, and explicit open and close are required in the code. For client systems involving a large number of database interactions, database connections need to be created frequently. When multiple clients connect to the database at the same time, it is easy to cause the database connection pool resources to be exhausted. There is a lack of unified database connection resource management, and there is a risk of exhaustion of critical resources for production database connections and unavailability of business systems. Summary of the invention

[0004] In view of the defects of database connection in the prior art, the present invention provides a database connection management method, comprising:

[0005] Receive database connection requests from clients;

[0006] Determining whether to accept the connection request according to a preset connection parameter threshold;

[0007] If it is determined that the connection request is accepted, the client is allowed to connect to the database.

[0008] In the embodiment of the present invention, the connection parameter thresholds include: a maximum connection threshold of a database and a preset priority application connection threshold.

[0009] In the embodiment of the present invention, judging whether to accept the connection request according to the preset connection parameter threshold comprises:

[0010] Determine whether the number of connections to the database is greater than the preset priority connection application threshold, and if the current number of connections to the database is less than the preset priority connection application threshold, accept the connection request;

[0011] If it is determined that the number of connections to the database is not less than the preset priority connection application threshold, then it is determined whether the current number of connections to the database is less than the maximum connection threshold of the database;

[0012] If it is determined that the value is less than the maximum connection threshold of the database, the connection request is accepted;

[0013] Determine whether the connection request is a preset priority connection request.

[0014] If it is determined to be a preset priority connection application, the connection request is accepted; otherwise, the connection request is rejected.

[0015] In the embodiment of the present invention, the determining to accept the connection request and allowing the client to connect to the database includes:

[0016] Determine to accept the connection request and generate a token for the current connection request;

[0017] The token is sent to the client and a database connection is opened to the client.

[0018] In the embodiment of the present invention, the determining to accept the connection request and allowing the client to connect to the database further includes:

[0019] Store the generated token and record the client's connection time.

[0020] At the same time, the present invention also provides a database connection management device, including:

[0021] A request receiving module, used for receiving a database connection request from a client;

[0022] A judgment module, for judging whether to accept the connection request according to a preset connection parameter threshold;

[0023] The request processing module determines to accept the connection request, and then allows the client to connect to the database.

[0024] In the embodiment of the present invention, the judging module judging whether to accept the connection request according to the preset connection parameter threshold comprises:

[0025] Determine whether the number of connections to the database is greater than the preset priority connection application threshold, and if the current number of connections to the database is less than the preset priority connection application threshold, accept the connection request;

[0026] If it is determined that the number of connections to the database is not less than the preset priority connection application threshold, then it is determined whether the current number of connections to the database is less than the maximum connection threshold of the database;

[0027] If it is determined that the value is less than the maximum connection threshold of the database, the connection request is accepted;

[0028] If it is determined that the value is not less than the maximum connection threshold of the database, then determining whether the connection request is a preset priority connection request;

[0029] If it is determined to be a preset priority connection application, the connection request is accepted; otherwise, the connection request is rejected.

[0030] In the embodiment of the present invention, the request processing module includes:

[0031] A token generation unit, determining to accept the connection request, and used to generate a token for the current connection request;

[0032] The connection unit is used to send the token to the client and develop a database connection to the client.

[0033] In the embodiment of the present invention, the request processing module further includes:

[0034] A storage unit is used to store the generated token and record the client's connection time.

[0035] At the same time, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the above method is implemented when the processor executes the computer program.

[0036] At the same time, the present invention also provides a computer-readable storage medium, which stores a computer program for executing the above method.

[0037] The present invention provides a database connection management method and device, which determines whether to accept the connection request according to a preset connection parameter threshold; if it is determined that the connection request is accepted, the client is allowed to connect to the database. Through the connection management service, the number of connection applications initiated by the client can be controlled according to the preset connection parameter threshold, and the connection with a high priority can be given priority when the connection resources are tight. The problem of service downtime caused by the uncontrollable number of connections is well solved, and the method of giving priority to the main connection improves the system availability.

[0038] In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0040] Figure 1 A flow chart of the database connection management method provided by the present invention;

[0041] Figure 2 It is a schematic diagram of an embodiment of the present invention;

[0042] Figure 3 It is a schematic diagram of an embodiment of the present invention;

[0043] Figure 4 A block diagram of the database connection management device provided by the present invention;

[0044] Figure 5 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] In the prior art, if there is no connection management measure when the client directly connects to the database, then when there are multiple clients and the same client operates the database concurrently, an excessive number of instantaneous connections will cause problems such as database downtime and application freezing.

[0047] To this end, the present invention provides a database connection management method, such as Figure 1 As shown, including:

[0048] Step S101, receiving a database connection request from a client;

[0049] Step S102, judging whether to accept the connection request according to a preset connection parameter threshold;

[0050] Step S103: determine that the connection request is accepted, and allow the client to connect to the database.

[0051] The database connection management method provided by the present invention determines whether to accept the connection request according to a preset connection parameter threshold, and provides a database connection management method that can be easily configured and uniformly managed in the background. When data connection resources are tight, the preset connection parameter threshold can be used to ensure that important connection applications are passed first, and secondary connection applications are blocked, thereby achieving the purpose of high availability of the system.

[0052] Furthermore, in the embodiment of the present invention, the connection parameter thresholds include: a maximum connection threshold of a database, and a preset priority application connection threshold.

[0053] In one embodiment of the present invention, by setting a maximum application threshold (i.e., the maximum connection threshold of the database) and a primary application limit threshold (i.e., a preset priority application connection threshold, the maximum application threshold must be greater than the primary application limit threshold), a connection application is accompanied by a connection priority parameter (primary or secondary, and the default is primary when not passed). When a connection application is made, it is first determined whether the number of surviving connections in the application record table exceeds the primary application limit threshold. If so, it is then determined whether the maximum application threshold is reached. If between the two, it is then determined whether the connection is a primary application. If it is a primary application, it is accepted, otherwise it is rejected.

[0054] Further, in an embodiment of the present invention, judging whether to accept the connection request according to a preset connection parameter threshold comprises:

[0055] Determine whether the number of connections to the database is greater than the preset priority connection application threshold, and if the current number of connections to the database is less than the preset priority connection application threshold, accept the connection request;

[0056] If it is determined that the number of connections to the database is not less than the preset priority connection application threshold, then it is determined whether the current number of connections to the database is less than the maximum connection threshold of the database;

[0057] If it is determined that the value is less than the maximum connection threshold of the database, the connection request is accepted;

[0058] Determine whether the connection request is a preset priority connection request.

[0059] If it is determined to be a preset priority connection application, the connection request is accepted; otherwise, the connection request is rejected.

[0060] Specifically, when there is a connection application, first determine whether the number of surviving connections in the application record table exceeds the primary application limit threshold. If it exceeds, check whether it reaches the maximum application threshold. If it is between the two, check whether the connection is a primary application. If it is a primary application, accept it, otherwise reject it. When the client application is rejected, a retry is initiated. The client can set the maximum number of retries. When the number of retries exceeds the maximum number of retries, the upstream is notified that the application for database resources has failed. This solves the problem of service downtime caused by the uncontrollable number of connections, and improves system availability by giving priority to primary connections.

[0061] Through the maximum connection threshold of the database, the priority connection threshold is preset to determine the number of connections, thereby solving the problem in the prior art that applications are divided into primary and secondary businesses. When the business volume increases and the database connection resources are tight, the availability of the primary business cannot be guaranteed.

[0062] In the embodiment of the present invention, the determining to accept the connection request and allowing the client to connect to the database includes:

[0063] Determine to accept the connection request and generate a token for the current connection request;

[0064] The token is sent to the client and a database connection is opened to the client.

[0065] Specifically, in the embodiment of the present invention, by setting a connection application record table, whenever there is a connection application, the token corresponding to the application is stored, and when the connection is closed, the token is synchronously sent to apply for closing. Thus, a JAVA-based database connection management method is provided, and the number of application connections initiated by the client can be controlled through the connection management server, and when the connection resources are tight, the connection with a high priority can be applied first.

[0066] In the embodiment of the present invention, the determining to accept the connection request and allowing the client to connect to the database further includes:

[0067] Store the generated token and record the client's connection time.

[0068] This avoids connection failures due to network and other reasons, but the connection application still occupies connection resources in the application table. The application table is monitored internally in the service, and connection applications that are not released within a fixed time are directly deleted.

[0069] Terminology explanation:

[0070] Token:

[0071] In computer identity authentication, it means "token". Token is a string of characters generated by the server as a token for the client request. In the present invention, when the client applies for the first time, a token is generated for the connection request and returned to the client. When the client requests to close the connection, it brings this token, and the server can determine which request it is based on the token.

[0072] socket

[0073] Socket is an abstraction of a breakpoint for bidirectional communication between application processes on different hosts in a network. A socket is one end of process communication on a network, providing a mechanism for application layer processes to exchange data using network protocols. In the present invention, socket is used as a communication means between the Delphi end and the JAVA end.

[0074] An embodiment of the present invention provides a client connection management device, which receives a database connection request from a client, determines whether to accept the connection request according to a preset connection parameter threshold, and allows the client to connect to the database if it is determined to accept the connection request, thereby overcoming the shortcomings of unlimited connections and lack of unified resource management in the prior art. An embodiment of the present invention provides a JAVA-based, easily configurable, and uniformly backend-managed database connection device; when data connection resources are tight, it can prioritize important connection applications and block secondary connection applications, thereby achieving the purpose of high system availability.

[0075] like Figure 2 As shown, it is a schematic diagram of connection management performed by the client connection management device provided in this embodiment. A java-based database connection management service is built on the server side, and the Delphi client and the connection management side communicate through socket.

[0076] The Delphi client sends an open request to the connection management server through the socket;

[0077] The application is successful, and the connection management server generates a token;

[0078] Return the generated token to the client for open connection;

[0079] The client sends a close request with a token through the socket;

[0080] The connection management server releases the connection;

[0081] Notify the client of successful release.

[0082] 1. In the embodiment of the present invention, a connection application record table is set in the memory of the connection management server. Whenever there is a connection application, a token corresponding to the application is stored. When the connection is closed, the token is synchronously sent to apply for closing;

[0083] 2. In the embodiment of the present invention, the connection management end sets the maximum application threshold maxConnectSize and the main application limit threshold mainMaxConnectSize. In the embodiment of the present invention, the maximum application threshold must be greater than the main application limit threshold.

[0084] The connection request comes with a connection priority parameter (primary or secondary, and the default is primary when not passed). When there is a connection request, first determine whether the number of surviving connections in the application record table exceeds the primary application limit threshold. If it exceeds, then check whether it reaches the maximum application threshold. If it is between the two, then check whether the connection is a primary application. If it is a primary application, accept it, otherwise reject it. When the client application is rejected, a retry is initiated. The client can set the maximum number of retries maxRetryTime. When the number of retries exceeds the maximum number of retries, the upstream is notified that the application for database resources has failed. Figure 3 FIG. 1 is a flow chart of connection number determination in an embodiment of the present invention.

[0085] In order to avoid connection failure due to network reasons, but the connection application still occupies connection resources in the application table, the application table is monitored internally in the service, and the connection application that is not released within a fixed time is directly deleted.

[0086] The embodiment of the present invention provides a JAVA-based database connection management device, which can control the number of connection applications initiated by the client through the connection management server, and can give priority to connections with high priority when connection resources are tight. It solves the service downtime problem caused by the uncontrollable number of connections, and improves the system availability by giving priority to the main connections.

[0087] At the same time, the present invention also provides a database connection management device, such as Figure 4 As shown, it is a block diagram of the database connection management device provided by the present invention, which includes:

[0088] The request receiving module 401 is used to receive a database connection request from a client;

[0089] A judgment module 402 judges whether to accept the connection request according to a preset connection parameter threshold;

[0090] The request processing module 403 determines to accept the connection request, and then allows the client to connect to the database.

[0091] The database connection management device provided by the present invention determines whether to accept the connection request according to a preset connection parameter threshold, and provides a database connection management method that can be easily configured and uniformly managed in the background. By using the preset connection parameter threshold, when data connection resources are tight, important connection applications can be given priority to ensure that they are passed, and secondary connection applications are blocked, thereby achieving the purpose of high availability of the system.

[0092] Furthermore, in the embodiment of the present invention, the connection parameter thresholds include: a maximum connection threshold of a database, and a preset priority application connection threshold.

[0093] In one embodiment of the present invention, the database connection management device sets a maximum application threshold (i.e., the maximum connection threshold of the database) and a primary application limit threshold (i.e., a preset priority application connection threshold, the maximum application threshold must be greater than the primary application limit threshold), and the connection application is accompanied by a connection priority parameter (primary or secondary, and the default is primary when not transmitted). When there is a connection application, it is first determined whether the number of surviving connections in the application record table exceeds the primary application limit threshold. If it exceeds, it is then determined whether it reaches the maximum application threshold. If it is between the two, it is then determined whether the connection is a primary application. If it is a primary application, it is accepted, otherwise it is rejected.

[0094] In the embodiment of the present invention, the judging module judging whether to accept the connection request according to the preset connection parameter threshold comprises:

[0095] Determine whether the number of connections to the database is greater than the preset priority connection application threshold, and if the current number of connections to the database is less than the preset priority connection application threshold, accept the connection request;

[0096] If it is determined that the number of connections to the database is not less than the preset priority connection application threshold, then it is determined whether the current number of connections to the database is less than the maximum connection threshold of the database;

[0097] If it is determined that the value is less than the maximum connection threshold of the database, the connection request is accepted;

[0098] If it is determined that the value is not less than the maximum connection threshold of the database, then determining whether the connection request is a preset priority connection request;

[0099] If it is determined to be a preset priority connection application, the connection request is accepted; otherwise, the connection request is rejected.

[0100] In the embodiment of the present invention, the request processing module includes:

[0101] A token generation unit, determining to accept the connection request, and used to generate a token for the current connection request;

[0102] The connection unit is used to send the token to the client and develop a database connection to the client.

[0103] In the embodiment of the present invention, the request processing module further includes:

[0104] A storage unit is used to store the generated token and record the client's connection time.

[0105] The database connection management device provided in this embodiment determines the number of connections through the maximum connection threshold of the database and the preset priority application connection threshold, thereby solving the problem in the prior art that applications are divided into primary services and secondary services. When the business volume increases and the database connection resources are tight, the availability of the primary services cannot be guaranteed.

[0106] In the embodiment of the present invention, the determining to accept the connection request and allowing the client to connect to the database includes:

[0107] Determine to accept the connection request and generate a token for the current connection request;

[0108] The token is sent to the client and a database connection is opened to the client.

[0109] In an embodiment of the present invention, whenever there is a connection application, the token corresponding to the application is stored, and when the connection is closed, the application to close the token is synchronously sent. Thus, a JAVA-based database connection management device is provided. Through the connection management server, the number of application connections initiated by the client can be controlled, and when the connection resources are tight, the connection with a high priority can be given priority. The generated token is stored and the connection time of the client is recorded. Connection failures due to network and other reasons are avoided, but the connection application still occupies connection resources in the application table, and the application table is monitored internally in the service. Connection applications that have not been released for a fixed time are directly deleted.

[0110] It should be noted that the database connection management method and device disclosed herein can be used for connection management of databases in the financial field, and can also be used for connection management of databases in any field other than the financial field. The application field of the database connection management method and device disclosed herein is not limited.

[0111] This embodiment also provides an electronic device, which may be a desktop computer, a tablet computer, a mobile terminal, etc., but this embodiment is not limited thereto. In this embodiment, the electronic device may refer to the embodiments of the aforementioned method and device, the contents of which are incorporated herein, and the repeated parts are not repeated.

[0112] Figure 5 FIG. 6 is a schematic block diagram of a system structure of an electronic device 600 according to an embodiment of the present invention. Figure 5 As shown, the electronic device 600 may include a central processor 100 and a memory 140; the memory 140 is coupled to the central processor 100. It should be noted that this figure is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.

[0113] In one embodiment, the database connection management function may be integrated into the central processor 100. The central processor 100 may be configured to perform the following control:

[0114] Receive database connection requests from clients;

[0115] Determining whether to accept the connection request according to a preset connection parameter threshold;

[0116] If it is determined that the connection request is accepted, the client is allowed to connect to the database.

[0117] In the embodiment of the present invention, the connection parameter thresholds include: a maximum connection threshold of a database and a preset priority application connection threshold.

[0118] In the embodiment of the present invention, judging whether to accept the connection request according to the preset connection parameter threshold comprises:

[0119] Determine whether the number of connections to the database is greater than the preset priority connection application threshold, and if the current number of connections to the database is less than the preset priority connection application threshold, accept the connection request;

[0120] If it is determined that the number of connections to the database is not less than the preset priority connection application threshold, then it is determined whether the current number of connections to the database is less than the maximum connection threshold of the database;

[0121] If it is determined that the value is less than the maximum connection threshold of the database, the connection request is accepted;

[0122] Determine whether the connection request is a preset priority connection request.

[0123] If it is determined to be a preset priority connection application, the connection request is accepted; otherwise, the connection request is rejected.

[0124] In the embodiment of the present invention, the determining to accept the connection request and allowing the client to connect to the database includes:

[0125] Determine to accept the connection request and generate a token for the current connection request;

[0126] The token is sent to the client and a database connection is opened to the client.

[0127] In the embodiment of the present invention, the determining to accept the connection request and allowing the client to connect to the database further includes:

[0128] Store the generated token and record the client's connection time.

[0129] In another embodiment, the database connection management device may be configured separately from the central processor 100. For example, the database connection management device may be configured as a chip connected to the central processor 100, and the database connection management function is implemented under the control of the central processor.

[0130] like Figure 5 As shown, the electronic device 600 may further include: a communication module 110, an input unit 120, an audio processing unit 130, a display 160, and a power supply 170. It is worth noting that the electronic device 600 does not necessarily have to include Figure 5 In addition, the electronic device 600 may also include Figure 5 For components not shown, reference may be made to the prior art.

[0131] like Figure 5 As shown, the central processor 100 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor devices and / or logic devices. The central processor 100 receives inputs and controls the operations of various components of the electronic device 600.

[0132] The memory 140 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The above-mentioned information related to the failure may be stored, and a program for executing the relevant information may also be stored. The CPU 100 may execute the program stored in the memory 140 to implement information storage or processing.

[0133] The input unit 120 provides input to the CPU 100. The input unit 120 is, for example, a key or a touch input device. The power supply 170 is used to provide power to the electronic device 600. The display 160 is used to display display objects such as images and text. The display may be, for example, an LCD display, but is not limited thereto.

[0134] The memory 140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 140 may also be some other type of device. The memory 140 includes a buffer memory 141 (sometimes referred to as a buffer). The memory 140 may include an application / function storage unit 142, which is used to store application programs and function programs or processes for executing the operation of the electronic device 600 through the central processor 100.

[0135] The memory 140 may also include a data storage unit 143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 144 of the memory 140 may include various drivers for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).

[0136] The communication module 110 is a transmitter / receiver 110 that transmits and receives signals via an antenna 111. The communication module (transmitter / receiver) 110 is coupled to the central processor 100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.

[0137] Based on different communication technologies, multiple communication modules 110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless LAN module. The communication module (transmitter / receiver) 110 is also coupled to a speaker 131 and a microphone 132 via an audio processor 130 to provide an audio output via the speaker 131 and receive an audio input from the microphone 132, thereby realizing a common telecommunication function. The audio processor 130 may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 130 is also coupled to the central processor 100, so that the sound can be recorded on the local machine through the microphone 132, and the sound stored on the local machine can be played through the speaker 131.

[0138] An embodiment of the present invention further provides a computer-readable program, wherein when the program is executed in an electronic device, the program enables a computer to execute the database connection management method as described in the above embodiment in the electronic device.

[0139] An embodiment of the present invention further provides a storage medium storing a computer-readable program, wherein the computer-readable program enables a computer to execute the database connection management described in the above embodiment in an electronic device.

[0140] The present invention provides a database connection management method and device, which can control the number of connection applications initiated by the client through the connection management server, and can give priority to connections with high priority when connection resources are tight. It solves the service downtime problem caused by the uncontrollable number of connections, and improves the system availability by giving priority to the main connections.

[0141] The preferred embodiments of the present invention have been described above with reference to the accompanying drawings. Many features and advantages of these embodiments are clear from this detailed description, and therefore the appended claims are intended to cover all such features and advantages of these embodiments that fall within their true spirit and scope. In addition, since many modifications and changes are readily apparent to those skilled in the art, the embodiments of the present invention are not intended to be limited to the precise structure and operation illustrated and described, but all suitable modifications and equivalents that fall within their scope may be included.

[0142] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0143] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0144] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0146] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A database connection management method, characterized in that: The method includes: Receive database connection requests from clients; Determine whether to accept the connection request according to a preset connection parameter threshold; the connection parameter threshold includes: a maximum connection threshold of the database, a preset priority connection threshold; wherein the maximum connection threshold of the database is greater than the preset priority connection threshold; Determining to accept the connection request, allowing the client to connect to the database; The determining whether to accept the connection request according to the preset connection parameter threshold comprises: Determine whether the number of connections to the database is greater than the preset priority connection application threshold, and if the current number of connections to the database is less than the preset priority connection application threshold, accept the connection request; If it is determined that the number of connections to the database is not less than the preset priority connection application threshold, then it is determined whether the current number of connections to the database is less than the maximum connection threshold of the database; If it is determined that the value is less than the maximum connection threshold of the database, the connection request is accepted; If it is determined that the value is not less than the maximum connection threshold of the database, it is determined whether the connection request is a preset priority connection application; whether the connection request is a preset priority connection application is determined according to a connection priority parameter attached to the connection request; the connection priority parameter is used to indicate a primary application or a secondary application. If the connection priority parameter is not transmitted when the connection request is transmitted, the connection request is assumed to be a primary application; If it is determined to be a preset priority connection application, the connection request is accepted, otherwise the connection request is rejected; When the number of times the client's database connection request is rejected exceeds the preset maximum number of retries, the upstream is notified that the application for database resources has failed.

2. The database connection management method according to claim 1, characterized in that: The determining to accept the connection request and allowing the client to connect to the database comprises: Determine to accept the connection request and generate a token for the current connection request; The token is sent to the client and a database connection is opened to the client.

3. The database connection management method according to claim 2, characterized in that: The determining to accept the connection request and allowing the client to connect to the database further comprises: Store the generated token and record the client's connection time.

4. A database connection management device, characterized in that: The device comprises: A request receiving module, used for receiving a database connection request from a client; A judgment module is configured to judge whether to accept the connection request according to a preset connection parameter threshold; the connection parameter threshold includes: a maximum connection threshold of a database and a preset priority connection threshold; wherein the maximum connection threshold of the database is greater than the preset priority connection threshold; The request processing module determines to accept the connection request, and then allows the client to connect to the database; The judging module judging whether to accept the connection request according to a preset connection parameter threshold comprises: Determine whether the number of connections to the database is greater than the preset priority connection application threshold, and if the current number of connections to the database is less than the preset priority connection application threshold, accept the connection request; If it is determined that the number of connections to the database is not less than the preset priority connection application threshold, then it is determined whether the current number of connections to the database is less than the maximum connection threshold of the database; If it is determined that the value is less than the maximum connection threshold of the database, the connection request is accepted; If it is determined that the value is not less than the maximum connection threshold of the database, it is determined whether the connection request is a preset priority connection application; whether the connection request is a preset priority connection application is determined according to a connection priority parameter attached to the connection request; the connection priority parameter is used to indicate a primary application or a secondary application. If the connection priority parameter is not transmitted when the connection request is transmitted, the connection request is assumed to be a primary application; If it is determined to be a preset priority connection application, the connection request is accepted, otherwise the connection request is rejected; When the number of times the client's database connection request is rejected exceeds the preset maximum number of retries, the upstream is notified that the application for database resources has failed.

5. The database connection management device according to claim 4, characterized in that: The request processing module includes: A token generation unit, determining to accept the connection request, and used to generate a token for the current connection request; The connection unit is used to send the token to the client and develop a database connection to the client.

6. The database connection management device according to claim 5, characterized in that: The request processing module also includes: A storage unit is used to store the generated token and record the client's connection time.

7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Server flow limiting method and system, computer equipment and storage medium

    CN109787908A

  • Database maintenance method and device

    CN110222034A