Data access method and device, computer equipment, medium and product
By using a proxy server to resolve and manage the database connection pool, the high cost of managing multiple database connections on the business server is solved, and efficient data access capabilities are achieved.
Patent Information
- Application Number
- CN202310900189.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-20
- Publication Date
- 2025-01-21
AI Technical Summary
In existing technologies, business servers need to manage a large number of database connections, resulting in high management costs and limited data access capabilities.
The proxy server receives data access requests from the business server, resolves the target database address, accesses the target database using a database connection pool, and returns the data access results. The business server only needs to connect to the proxy server, which centrally manages access to different databases.
It reduced the management cost of business servers, improved data access capabilities, simplified the database management process, and enhanced the efficiency and security of access control.
Smart Images

Figure CN119342095A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data access method, a data access device, a computer equipment, a computer-readable storage medium, and a computer program product. Background Art
[0002] Data access refers to accessing information stored in a database and performing corresponding operations by obtaining information. At present, most data access methods are implemented by database proxies. For example, adding a corresponding database proxy in front of each database instance can achieve database connection convergence and read-write separation capabilities, but the disadvantages are also obvious. If the business wants to access data from multiple databases, it needs to establish connections to multiple database instances, which means that the business party needs to manage a large number of database connections, which has high management costs and limited data access capabilities.
[0003] Therefore, how to reduce the management cost of business servers and improve data access capabilities has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present application provide a data access method, apparatus, computer equipment, medium, and product, which can reduce the management cost of the business party and improve the data access capability during the data access process.
[0005] On the one hand, an embodiment of the present application discloses a data access method, the method comprising:
[0006] The proxy server receives a data access request sent by the business server, wherein the data access request includes data access information and database location information;
[0007] The proxy server parses the data access request to obtain a database address of a target database corresponding to the database location information, wherein the database address of the target database is any one of database addresses of at least one database, and the at least one database is a database authorized to the proxy server;
[0008] The proxy server determines a database connection pool corresponding to the target database according to a database address of the target database;
[0009] The proxy server uses the database connection pool to access the target database, obtains a data access result corresponding to the data access information, and returns the data access result to the business server.
[0010] On the one hand, an embodiment of the present application discloses a data access method, the method comprising:
[0011] The business server determines a data access request, where the data access request includes data access information and database location information;
[0012] The business server sends a data access request to the proxy server, wherein the data access request is used to instruct the proxy server to access the target database according to the database address of the target database to obtain a data access result, wherein the database address of the target database is obtained by parsing the data access request, and the database address of the target database is any one of the database addresses of at least one database, and the at least one database is a database authorized to the proxy server;
[0013] The business server receives the data access result returned by the proxy server.
[0014] In one aspect, an embodiment of the present application discloses a data access device, the device comprising:
[0015] A transceiver unit, configured to receive a data access request sent by a business server, wherein the data access request includes data access information and database location information;
[0016] a processing unit, configured to parse the data access request to obtain a database address of a target database corresponding to the database location information, wherein the database address of the target database is any one of database addresses of at least one database, and the at least one database is a database authorized to the proxy server;
[0017] A determination unit, configured to determine a database connection pool corresponding to the target database according to a database address of the target database;
[0018] The transceiver unit is further used to access the target database using the database connection pool, obtain a data access result corresponding to the data access information, and return the data access result to the business server.
[0019] In one aspect, an embodiment of the present application discloses a data access device, the device comprising:
[0020] a determining unit, configured to determine a data access request, wherein the data access request includes data access information and database location information;
[0021] a transceiver unit, configured to send a data access request to a proxy server, wherein the data access request is used to instruct the proxy server to access the target database according to the database address of the target database to obtain a data access result, wherein the database address of the target database is obtained by parsing the data access request, and the database address of the target database is any one of the database addresses of at least one database, and the at least one database is a database authorized to the proxy server;
[0022] The transceiver unit is further used to receive the data access result returned by the proxy server.
[0023] On the one hand, an embodiment of the present application discloses a computer device, which includes a processor suitable for implementing one or more computer programs; and a computer storage medium, wherein the computer storage medium stores one or more computer programs, and the one or more computer programs are suitable for being loaded by the processor and executed in accordance with the above-mentioned data access method.
[0024] In one aspect, the present application discloses a computer-readable storage medium storing one or more computer programs, wherein the one or more computer programs are suitable for being loaded by a processor and executing the above-mentioned data access method.
[0025] The present application discloses a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned data access method.
[0026] In an embodiment of the present application, the business server is connected to a designated proxy server and sends a data access request to the proxy server. After receiving the data access request sent by the business server, the proxy server parses the data access request to obtain the database address of the target database, and then determines the database connection pool corresponding to the target database according to the database address of the target database, and uses the database connection pool to access the target database to obtain the data access result corresponding to the data access information. Finally, the proxy server returns the data access result directly to the business server. During the data access process, the business server only needs to connect to the designated proxy server, and then the data access process for different databases is centrally managed and processed by the designated proxy server to obtain the data access result. This can reduce the management cost of the business server and improve the data access capability. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the embodiments of the present application 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 It is a schematic diagram of a network architecture of a data access system disclosed in an embodiment of the present application;
[0029] Figure 2 It is a flowchart of a data access method disclosed in an embodiment of the present application;
[0030] Figure 3a is a schematic diagram of a database connection pool provided in an embodiment of the present application;
[0031] Figure 3b is a database connection pool of an illustrative target database provided in an embodiment of the present application;
[0032] Figure 4 It is a schematic diagram of a proxy server processing process disclosed in an embodiment of the present application;
[0033] Figure 5 It is a flowchart of another data access method disclosed in an embodiment of the present application;
[0034] Figure 6 It is a flowchart of another data access method disclosed in an embodiment of the present application;
[0035] Figure 7 It is a structural diagram of a data access device disclosed in an embodiment of the present application;
[0036] Figure 8 It is a structural diagram of another data access device disclosed in an embodiment of the present application;
[0037] Fig. 9 It is a structural schematic diagram of a computer device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0039] In order to more clearly understand the technical solution provided by the embodiments of the present application, some key terms involved in the embodiments of the present application are first introduced here:
[0040] 1. Database Instance
[0041] A database instance is a database server. One or more databases can be created within a database instance.
[0042] 2. Database Agent
[0043] The business accesses the database through a database proxy, which can provide some other functions for the database, and the database proxy can also be understood as a database instance. In the embodiment of the present application, the business can be understood as a business server, and the database proxy can be understood as a proxy server, through which access to any database can be achieved.
[0044] MySQL Protocol
[0045] MySQL protocol is a network protocol used for MySQL database communication. Through this protocol, the client can communicate with the MySQL server, send SQL statements, obtain query results and other operations. The MySQL protocol is based on the TCP / IP protocol, and the communication between the client and the server is carried out through a TCP connection. After the connection is established, the client will send a handshake request to the server, and the server will return a handshake response to complete the connection establishment. After that, the client can send SQL statement requests to the server, and the server will parse the SQL statement and return the corresponding results. The data of the MySQL protocol mainly includes:
[0046] 1. Handshake database package: When the client and server establish a connection, the server will send a handshake data packet to the client, which contains the server version number, authentication information, etc.;
[0047] 2. Authentication data packet: After the client receives the handshake data packet from the server, it will send an authentication data packet to the server to complete the connection authentication;
[0048] 3. Query data packet: When the client sends a SQL statement request, it will send a query data packet to the server, including the SQL statement and query options;
[0049] 4. Result data packet: After receiving the query data packet, the server will parse the SQL statement and return the result data packet to the client, which includes the query results and result set information.
[0050] The underlying principle of the MySQL protocol is to complete the communication between the client and the server through these data packets, thereby realizing the functions of the MySQL database.
[0051] Among them, the full name of SQL in English is Structured Query Language, which is a special-purpose programming language and a database query and programming language used to access data as well as query, update and manage relational database systems.
[0052] 4. Cloud Technology
[0053] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application. It can form a resource pool, which is used on demand and is flexible and convenient. Cloud computing technology will become an important support. Cloud storage is a new concept extended and developed from the concept of cloud computing. Distributed cloud storage system (hereinafter referred to as storage system) refers to a storage system that uses cluster applications, grid technology and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide data storage and business access functions to the outside world. In short, a database can be regarded as an electronic filing cabinet - a place to store electronic files. Users can add, query, update, delete and other operations on the data in the files. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application program.
[0054] 5. Blockchain
[0055] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of the information (anti-counterfeiting) and generate the next block.
[0056] In order to solve the problem that the demand for accessing any database instance through one database instance cannot be met, an embodiment of the present application provides a data access solution, which includes: ① The proxy server receives a data access request sent by a business server, and the data access request includes data access information and database location information. The database location information is carried in the data access request, and the database to be accessed can be located through the database location information. ② The proxy server parses the data access request to obtain the database address of the target database corresponding to the database location information, and the database address of the target database is any one of the database addresses of at least one database, and at least one database is a database authorized to the proxy server. The proxy server stores a batch of database addresses of authorized databases. After determining the database location information, the database address of the target database can be determined from the batch of authorized database addresses. Multiple databases only need to authorize one proxy server, and do not need to authorize other proxy servers, thereby improving the efficiency and security of permission management. ③ The proxy server determines the database connection pool corresponding to the target database according to the database address of the target database. ④ The proxy server uses the database connection pool to access the target database, obtains the data access result corresponding to the data access information, and returns the data access result to the business server. Through this method, it is possible to access any database instance through one database instance. In this process, the business server only needs to connect to a proxy server, which can parse any data access request from the business server to obtain the database address of the target database, and can access the corresponding database according to the database address to obtain the data access result. This can reduce the management cost of the business server, improve business development efficiency and enhance data access capabilities.
[0057] In a possible implementation, the data access method provided by the present application can be implemented based on cloud technology. Specifically, it can involve one or more of cloud storage, cloud database, and big data in cloud technology. For example, the data access request received by the proxy server can be obtained by the business server from the cloud database, or the database connection pool corresponding to the target database can also be obtained from the cloud database.
[0058] In a possible implementation, the data access method provided by the present application can also be implemented based on blockchain technology. For example, the data required to execute the data access method can be stored in the form of blocks on the blockchain; specifically, the data generated by executing the data access method (such as the database connection pool corresponding to the target database and the data access result corresponding to the data access request, etc.) can be stored in the form of blocks on the blockchain; in addition, the data access device that executes the data access method can be a node device in the blockchain network.
[0059] See also Figure 1 , is a schematic diagram of the architecture of a data access system disclosed in an embodiment of the present application. The data access system may include at least one business server 101, a proxy server 102, and N database instances 103 (databases), where N is an integer. Specifically, the business server 101 may be a specific business in different business scenarios, such as reconciliation business, transfer business, and payment business, etc.; the business server 101 is mainly used to send data access requests to the proxy server 102, and receive data access results sent by the proxy server 102. The proxy server 102 can also be a database or a database instance; the proxy server 102 is mainly used to parse the data access request, obtain the database address of the target database, and then determine the database connection pool corresponding to the target database according to the database address of the target database, and finally determine the data access result according to the database connection pool, and return the data access result to the business server 101. Optionally, the proxy server 102 may be integrated with a parsing engine, a routing engine, and an execution engine, that is, three modules connected in series, and there is a data flow: the parsing engine parses the data access request to obtain the database address of the target database; the routing engine uses the database connection pool of the database address of the target database obtained by the parsing engine; the execution engine determines the data access result according to the database connection pool transmitted by the routing engine. Each engine cooperates and jointly executes the data access method. The database instance 103 may also be a specific database or a database server. The database instance 103 stores data corresponding to various businesses. Different database instances 103 (such as instance 1, instance 2, instance 3, ..., instance N) may also directly authorize the same proxy server 102. Optionally, when there is a new database, the database instance 103 may send the database address of the new database to the business server 101 and the proxy server 102.
[0060] In one embodiment, the business server 101 and the proxy server 102 can be independent physical servers, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms, which are not limited in this embodiment of the present application. The business server 101 can be directly connected to a terminal device, which includes but is not limited to: smart phones, tablet computers, smart wearable devices, smart voice interaction devices, smart home appliances, personal computers, vehicle-mounted terminals, smart cameras, virtual reality devices (such as AR (Augmented Reality) devices), etc., which are very popular in this application. The database instance 103 may also be a database server, an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, but the embodiments of the present application do not limit this.
[0061] The business server 101 and the proxy server 102 may establish a direct communication connection through wired communication, or may establish an indirect communication connection through wireless communication. The proxy server 102 and all database instances 103 may establish a direct communication connection through wired communication, or may establish an indirect communication connection through wireless communication, and all databases connected to the proxy server 102 authorize their database addresses to the proxy server 102.
[0062] In an embodiment of the present application, in combination with the data access system, the data access method may include: the business server 102 determines the data access request, sends the data access request to the proxy server 102, the proxy server 102 parses the data access request, obtains the database address of the target database corresponding to the database location information, the database address of the target database is any one of the database addresses of at least one database, and at least one database is a database authorized to the proxy server. That is, all databases connected to the proxy server are authorized to the proxy server, and the proxy server 102 can directly access these databases without the participation of other proxy servers, nor does it need to be authorized to other proxy servers, thereby improving the efficiency and security of authority management. The proxy server 102 determines the database connection pool corresponding to the target database according to the database address of the target database, and then uses the database connection pool to access the target database to obtain the data access result corresponding to the data access information. Finally, the proxy server 102 returns the data access result to the business server 101. In this process, the business server only needs to connect to a proxy server, which can parse any data access request from the business server to obtain the database address of the target database, and can access the corresponding database according to the database address to obtain the data access result, thereby reducing the management cost of the business server and improving data access capabilities.
[0063] In one implementation, the data access method can be applied to various application scenarios, including reconciliation business scenarios, transfer business scenarios, payment business scenarios, etc. In a feasible implementation, the data access method provided in the embodiment of the present application can support various core financial systems. Since the data access method is highly scalable, it can support the continuous access and use of new business systems.
[0064] It should be noted that in this application, the relevant data involved in the data method process, such as database access requests, database addresses, and database connection pools, etc. When the above embodiments of this application are applied to specific products or technologies, user permission or consent must be obtained, and the relevant data collection, use, and processing processes must comply with relevant national and regional laws, regulations, and standards, and comply with the principles of legality, legitimacy, and necessity, and do not involve obtaining data types prohibited or restricted by laws and regulations. In some optional embodiments, the relevant data involved in the embodiments of this application are obtained after the object has been authorized separately. In addition, when obtaining the object's separate authorization, the purpose of the relevant data involved is indicated to the object.
[0065] The data access method proposed in the embodiment of the present application is introduced in detail below.
[0066] See also Figure 2, is a flow chart of a data access method disclosed in an embodiment of the present application. The data access method is described with a proxy server as the execution subject. Correspondingly, the data access method may include but is not limited to the following steps:
[0067] S201: The proxy server receives a data access request sent by the business server, where the data access request includes data access information and database location information.
[0068] In a possible implementation, the data access request is determined by the business server. Specifically, the business server first determines the data access information, then determines the database location information matching the data access information from the database location list according to the data access information, and finally encapsulates the data access information and the database location information through the database communication protocol to obtain the data access request. The data access information constitutes a data query statement, and the database location information is marked with the annotation information of the database query statement. The annotation information is used to mark the database location information, and the annotation information is direct and simple, so it can effectively reduce the learning cost of the business party.
[0069] It should be noted that the proxy server and the business server are connected in communication, that is, the business server knows the location information of the proxy server, and the connection between the proxy server and the business server is realized based on the location information of the proxy server. Therefore, the business server can determine where to send the data access request, and the proxy server can also accurately receive the data access request sent by the business server. The proxy database is unique, so the proxy server can receive data access requests sent by any business server, and all of them are processed by the proxy server.
[0070] Optionally, the proxy server receives one data access request at a time, or may receive N data requests at a time, and the number received depends on the number sent by the business server.
[0071] S202: The proxy server parses the data access request to obtain a database address of a target database corresponding to the database location information, wherein the database address of the target database is any one of database addresses of at least one database, and at least one database is a database authorized to the proxy server.
[0072] In a possible implementation, after receiving the data access request, the proxy server parses the data access request, and the parsing process includes: the proxy server parses the data access request (including the database query statement and the annotation information of the database query statement) through the database communication protocol to obtain the character information corresponding to the data access request. Then, the database address of the target database matching the database location information is obtained from the character information corresponding to the data access request. Among them, the parsing process can be specifically a decoding process, and the database communication protocol can specifically refer to the MySQL protocol.
[0073] In an embodiment of the present application, one data access request corresponds to one target database, and the parsing engine of the proxy server can determine the database address of a target database based on one data access request. Optionally, the parsing engine can parse N data access requests in parallel to obtain N database addresses, and the proxy server can realize centralized processing of data access requests, without sending data access requests directly to the database, thereby improving the management efficiency of data access requests. Among them, the database address of any target database is any one of the database addresses of at least one database (the proxy server stores the database addresses of multiple databases), and at least one database is a database authorized to the proxy server, and these databases have authorized the proxy server. Since in this process, only one proxy server is needed to process these data access requests, the database only needs to authorize the proxy server, and there is no need to authorize other proxy servers, so the efficiency and security of authority management can be improved.
[0074] S203: The proxy server determines a database connection pool corresponding to the target database according to the database address of the target database.
[0075] In a possible implementation, the process of the proxy server determining the database connection pool corresponding to the target database may include: the proxy server queries whether there is a database connection pool corresponding to the target database in the proxy server according to the database address of the target database; if there is a database connection pool corresponding to the target database in the proxy server, the database connection pool corresponding to the target database is directly obtained from the proxy server; if there is no database connection pool corresponding to the target database in the proxy server, the database connection pool corresponding to the target database is created according to the target database address. The corresponding creation process may include: first determining the connection between the business server and the target database, and then adding the connection to the corresponding database connection pool.
[0076] One target database corresponds to one database connection pool, and the proxy server can manage multiple database connection pools at the same time. Figure 3a, is a schematic diagram of a database connection pool disclosed in an embodiment of the present application, Figure 3a For example, if the same business party needs to access three databases, the corresponding target databases may include the first database, the second database, and the third database. Figure 3a As shown, the first database corresponds to a database connection pool, the second database corresponds to a database connection pool, and the third database corresponds to a database connection pool. The proxy server can manage these three database connection pools at the same time.
[0077] S204: The proxy server uses the database connection pool to access the target database, obtains a data access result corresponding to the data access information, and returns the data access result to the business server.
[0078] In a possible implementation, the proxy server determines the database connection used by the business server from the database connection pool corresponding to the target database, where the database connection includes a newly created connection and an idle connection, and then the proxy server uses the database connection used by the business server to obtain the data access result corresponding to the data access information from the target database. An idle connection means that the connection has been created and is used to connect the business server and the target database.
[0079] like Figure 3b As shown, a database connection pool of a target database disclosed in an embodiment of the present application may include idle connections and newly created connections. For any data access request to access the target database, one of the idle connections and the newly created connections may be used to obtain the data access result corresponding to the data access request.
[0080] In a possible implementation, if there is a new database, the new database sends its location information to the proxy server to authorize the proxy server. If there is a data access request for the new database, the proxy server can also obtain the corresponding data access result according to the above process. Therefore, if a new database and database instance are added, it is only necessary to authorize the proxy server, and the business server does not need to be modified accordingly. Therefore, the development efficiency of the business party can be improved, and the scalability is relatively strong.
[0081] Optionally, the data access method is applicable not only to the data reading process, but also to the data writing process. In the actual implementation process, the read-write flag can be carried in the data access request, and then the database connection pool of the corresponding database is determined. Reading and writing can correspond to different database connection pools, that is, reading corresponds to one database connection pool and writing corresponds to another database connection pool. Based on this, read-write separation can be efficiently implemented.
[0082] In an optional embodiment, a parsing engine, a routing engine and an execution engine may be deployed on the proxy server, wherein the parsing engine is specifically used to execute step S202, the routing engine is specifically used to execute step S203, and the execution engine is specifically used to execute step S204. Further, in combination with the engines in each proxy server, steps S202-S203 may be used. Figure 4 The flowchart shown is specifically described, and the process may include: ① The parsing engine of the proxy server decodes the data access request; ② The parsing engine extracts the annotation information of the database query statement; ③ The routing engine establishes a connection between the target database and the business server; ④ The execution engine executes the database query statement in the data access request to obtain the data access result. The parsing engine, the routing engine, and the execution engine are mainly responsible for processing the data access request to obtain the data access result.
[0083] In the embodiment of the present application, the proxy server is used as the execution subject, and the processing process of the proxy server for data access request is explained, including: parsing the data access request to obtain the database address of the target database; determining the database connection pool corresponding to the target database according to the database address of the target database; using the database connection pool to access the target database, obtain the data access result corresponding to the data access information and return the data access result to the business server. In this process, only one proxy server is needed to process any data access request, and centralized management and processing of a proxy server is realized, thereby reducing the management cost of the proxy server and improving data access capabilities.
[0084] See also Figure 5 , is a flow chart of another data access method disclosed in an embodiment of the present application. The data access method is described with the business server as the execution subject. The data access method may include but is not limited to the following steps:
[0085] S501: The business server determines a data access request, where the data access request includes data access information and database location information.
[0086] In a possible implementation, the business server first determines the data access information. The data access information can be sent by the client, that is, it is sent when there is a demand; the data access information can also be triggered by the business server itself. For different businesses, different timers can be used to achieve timed triggering. Then the business server determines the database location information that matches the data access information from the database location list according to the data access information. The database location list stores all the location information of the database. Each piece of data consists of a database identifier and database location information. For any data access information, the identifier corresponding to the database can be parsed from the data access information, and then the database location information that matches the data access information can be found from the database location list according to the identifier corresponding to the database. Finally, the business server encapsulates the data access information and the database location information through the database communication protocol to obtain a data access request. The actual encapsulation process is: the business server generates a database query statement using the database communication protocol and the data access information; the business server sets the database location information as the annotation information of the database query statement through the database communication protocol, that is, marks the database location information in the form of annotations; adding the database location information in the form of annotations is relatively simple to apply and easy to understand, and does not require learning costs. The business server encapsulates the database query statement and the annotation information of the database query statement through the database communication protocol to obtain a data access request. The encapsulation process may be encoding the database query statement and the annotation information. It should be noted that the form of the annotation information complies with the database communication protocol. In this way, data access with or without adding the database location information can be guaranteed.
[0087] Optionally, if there is a newly added database, the database location list can be updated according to the database address of the newly added database. The business server receives an instruction to add a newly added database address, which may be initiated by a developer, and then responds to the instruction to add the newly added database address and adds the newly added database address to the database location list. If the newly added database is to be accessed, the database location information of the newly added database can be directly added to the annotation information of the database access statement in the form of annotation information, without the need for the business party to perform complex operations. It is relatively easy to implement and can reduce the opening cost of the business party.
[0088] S502: The business server sends a data access request to the proxy server. The data access request is used to instruct the proxy server to access the target database according to the database address of the target database to obtain a data access result. The database address of the target database is obtained by parsing the data access request. The database address of the target database is any one of the database addresses of at least one database, and at least one database is a database authorized to the proxy server.
[0089] In a possible implementation, before the business server sends a data access request to the proxy server, a communication connection between the business server and the proxy server may be established first. Specifically, the business server receives the unique location information of the proxy server sent by the proxy server, and establishes a communication connection between the business server and the proxy server based on the unique location information. Optionally, the communication connection between the business server and the proxy server may also be established while the business server sends a data access request to the proxy server. Specifically, after the business server receives the unique location information of the proxy server, when sending a data access request to the proxy server, the business server carries the unique location information in the data access request, thereby achieving communication connection and data transmission at the same time.
[0090] Among them, when the business server sends a data access request to the proxy server, it can send the data access request serially according to a communication connection, or it can establish multiple communication connections through the unique location information of the proxy server and send data access requests to the proxy server in parallel. No matter how many data access requests the business server wants to send, they are all sent to the designated proxy server, and there is no need to establish connections with other proxy servers. Optionally, there is more than one business server, and for different businesses, different business servers can send corresponding data access requests to the proxy server. After sending the data access request to the proxy server, the proxy server accesses the target database according to the database address of the target database and obtains the data access result. For details of this process, please refer to Figure 2 The relevant steps shown are not repeated here.
[0091] S503: The business server receives the data access result returned by the proxy server.
[0092] After the proxy server determines the data access result according to the data access request, the proxy server sends the data access result to the business server. The business server receives the data access result returned by the proxy server and can further process the data access result. If the data access information in the data access request is sent by the client, the data access result is returned to the client; if the data access information in the access request is triggered by the business server itself, the business server records the data access result. For different business scenarios, verification can also be performed or prompt information can be sent to the client.
[0093] In the embodiment of the present application, the business server is used as the execution subject, and the process of determining the data access request by the business server and how to establish a communication connection with the proxy server are explained. In this process, the business server no longer needs to maintain and manage the addresses of multiple proxy servers as before, but can access any number of databases through one address of the proxy server. The database only needs to authorize the proxy server, which can improve the efficiency and security of authority management. In addition, if a new database is added, it only needs to authorize the same proxy server, and the location information of the database is marked in the form of annotation information. Therefore, the business server does not need to be complicatedly modified, and the scalability is extremely strong.
[0094] The following describes the data access method disclosed in the embodiment of the present application in the form of interaction between the business server and the proxy server. Figure 6 , is a flow chart of another data access method disclosed in an embodiment of the present application, comprising the following steps:
[0095] S601: The business server determines a data access request, where the data access request includes data access information and database location information.
[0096] S602: The business server sends a data access request to the proxy server.
[0097] S603: The proxy server parses the data access request to obtain the database address of the target database corresponding to the database location information.
[0098] S604: The proxy server determines a database connection pool corresponding to the target database according to the database address of the target database.
[0099] S605: The proxy server uses the database connection pool to access the target database and obtains a data access result corresponding to the data access information.
[0100] S606: The proxy server returns the data access result to the service server.
[0101] This process mainly describes the data access method in an interactive form, wherein steps S601-S602 are Figure 5 The relevant steps are described in detail, steps S603-S606 are described in detail. Figure 2 The relevant steps have been described in detail and will not be repeated here. Figure 6It can be seen that for any data access request, the corresponding data access result can be successfully obtained through the business server. Therefore, if the data access method provided by the embodiment of the present application is adopted, the business server no longer needs to manage the complex and cumbersome addresses of multiple proxy servers (i.e., data proxies), and can request multiple database instance addresses at the same time. It has strong horizontal expansion, and the new database address does not need to be modified for business, and the new database location information can be directly added. By marking the database location information in the form of annotation information, the business development efficiency can be effectively improved, the transformation and learning costs can be reduced, and the data access capability can be effectively improved.
[0102] The method of the embodiment of the present application is described in detail above. In order to facilitate better implementation of the above scheme of the embodiment of the present application, the device of the embodiment of the present application is provided below accordingly.
[0103] See also Figure 7 , Figure 7 It is a structural diagram of a data access device provided in an embodiment of the present application. The data access device can be set in a computer device provided in an embodiment of the present application, and the computing device can be a proxy server. Figure 7 The data access device shown may be a computer program (including program code) running in a computer device, and the data access device may be used to execute Figure 2 as well as Figure 6 Some or all of the steps in the method embodiment shown. Figure 7 , the data access device may include the following units:
[0104] The transceiver unit 701 is used to receive a data access request sent by a business server, wherein the data access request includes data access information and database location information;
[0105] The processing unit 702 is used to parse the data access request to obtain a database address of a target database corresponding to the database location information, wherein the database address of the target database is any one of database addresses of at least one database, and the at least one database is a database authorized by the proxy server;
[0106] A determination unit 703 is used to determine a database connection pool corresponding to the target database according to a database address of the target database;
[0107] The transceiver unit 701 is further configured to access the target database using the database connection pool, obtain a data access result corresponding to the data access information, and return the data access result to the business server.
[0108] In a possible implementation, when the processing unit 702 parses the data access request and obtains the database address of the target database corresponding to the database location information, it is specifically configured to perform the following steps:
[0109] Parsing the data access request through a database communication protocol to obtain character information corresponding to the data access request;
[0110] A database address of a target database matching the database location information is obtained from the character information corresponding to the data access request.
[0111] In a possible implementation, the data access request includes a database query statement and annotation information of the database query statement, the database query statement includes data access information, and the annotation information includes database location information.
[0112] In a possible implementation, when the determination unit 703 determines the database connection pool corresponding to the target database according to the database address of the target database, it is specifically configured to perform the following steps:
[0113] Querying a database connection pool corresponding to the target database according to the database address of the target database;
[0114] If there is a database connection pool corresponding to the target database, obtain the database connection pool corresponding to the target database;
[0115] If the database connection pool corresponding to the target database does not exist, a database connection pool corresponding to the target database is created according to the target database address.
[0116] In a possible implementation, the processing unit 702 uses the database connection pool to access the target database, and when obtaining the data access result corresponding to the data access information, is specifically configured to perform the following steps:
[0117] Determine a database connection used by the business server from a database connection pool corresponding to the target database, wherein the database connection includes one of a newly created connection and an idle connection;
[0118] The data access result corresponding to the data access information is obtained from the target database using the database connection used by the business server.
[0119] According to another embodiment of the present application, Figure 7The various units in the data access device shown can be respectively or all merged into one or several other units to constitute, or some of the units (some) can also be split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effect of the embodiment of the application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be realized by multiple units, or the function of multiple units can be realized by one unit. In other embodiments of the application, the data access device can also include other units. In practical applications, these functions can also be assisted by other units to be realized, and can be realized by the collaboration of multiple units.
[0120] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 2 or Figure 6 A computer program (including program code) for each step involved in part or all of the method shown in the figure is used to construct a computer program (including program code) for each step involved in part or all of the method shown in the figure. Figure 7 The data access device shown in the embodiment of the present application is implemented by the data access method. The computer program can be recorded on a computer-readable storage medium, for example, and loaded into the above-mentioned computing device through the computer-readable storage medium and run therein.
[0121] In the embodiment of the present application, the processing unit of the proxy server parses the data access request to obtain the database address of the target database; determines the database connection pool corresponding to the target database according to the database address of the target database; uses the database connection pool to access the target database, obtains the data access result corresponding to the data access information, and returns the data access result to the business server through the transceiver unit. In this process, only one proxy server is needed to process any data access request, realizing centralized management and processing of a proxy server, thereby reducing the management cost of the proxy server and improving data access capabilities.
[0122] See also Figure 8 , Figure 8 It is a structural diagram of another data access device provided in an embodiment of the present application. The data access device can be set in the computer device provided in the embodiment of the present application, and the computing device can be a business server. Figure 8 The data access device shown may be a computer program (including program code) running in a computer device, and the data access device may be used to execute Figure 5 as well as Figure 6 Some or all of the steps in the method embodiment shown. Figure 8, the data access device may include the following units:
[0123] A determining unit 801 is used to determine a data access request, where the data access request includes data access information and database location information;
[0124] The transceiver unit 802 is used to send a data access request to the proxy server, wherein the data access request is used to instruct the proxy server to access the target database according to the database address of the target database to obtain a data access result, wherein the database address of the target database is obtained by parsing the data access request, and the database address of the target database is any one of the database addresses of at least one database, and the at least one database is a database authorized by the proxy server;
[0125] The transceiver unit 802 is further configured to receive the data access result returned by the proxy server.
[0126] In a possible implementation, when the determining unit 801 determines the data access request, it is specifically configured to perform the following steps:
[0127] Determine data access information;
[0128] Determine, from a database location list according to the data access information, database location information that matches the data access information;
[0129] The data access information and the database location information are encapsulated and processed through a database communication protocol to obtain a data access request.
[0130] In a possible implementation, the processing unit 803 encapsulates the data access information and the database location information through a database communication protocol, and when a data access request is obtained, is specifically used to perform the following steps: the business server generates a database query statement using the database communication protocol and the data access information;
[0131] Setting the database location information as annotation information of the database query statement through the database communication protocol;
[0132] The database query statement and the annotation information of the database query statement are encapsulated and processed through the database communication protocol to obtain a data access request.
[0133] According to another embodiment of the present application, Figure 8The various units in the data access device shown can be respectively or all merged into one or several other units to constitute, or some of the units (some) can also be split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effect of the embodiment of the application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be realized by multiple units, or the function of multiple units can be realized by one unit. In other embodiments of the application, the data access device can also include other units. In practical applications, these functions can also be assisted by other units to be realized, and can be realized by the collaboration of multiple units.
[0134] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 5 or Figure 6 A computer program (including program code) for each step involved in part or all of the method shown in the figure is used to construct a computer program (including program code) for each step involved in part or all of the method shown in the figure. Figure 7 The data access device shown in the embodiment of the present application is implemented by the data access method. The computer program can be recorded on a computer-readable storage medium, for example, and loaded into the above-mentioned computing device through the computer-readable storage medium and run therein.
[0135] Based on the above method and device embodiments, the present application embodiment provides a computer device. Fig. 9 , Fig. 9 is a schematic diagram of a computer device provided in an embodiment of the present application. The computer device may be Figure 1 The service server 101 shown may also be Figure 1 A proxy server 102 is shown. Fig. 9 The computer device shown includes at least a processor 901, an input interface 902, an output interface 903, and a computer-readable storage medium 904. The processor 901, the input interface 902, the output interface 903, and the computer-readable storage medium 904 may be connected via a bus or other means.
[0136] The computer-readable storage medium 904 may be stored in a memory of a computer device. The computer-readable storage medium 904 is used to store a computer program. The computer program includes computer instructions. The processor 901 is used to execute the program instructions stored in the computer-readable storage medium 904. The processor 901 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device, which is suitable for implementing one or more computer instructions, and is specifically suitable for loading and executing one or more computer instructions to implement a corresponding method flow or a corresponding function.
[0137] The embodiment of the present application also provides a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space that stores the operating system of the computer device. In addition, one or more computer instructions suitable for being loaded and executed by the processor are also stored in the storage space. These computer instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory (Non-VolatileMemory), such as at least one disk storage; optionally, it can also be at least one computer-readable storage medium located away from the aforementioned processor.
[0138] When the computer device is a service server 101, the processor 901 may load and execute one or more computer instructions stored in the computer-readable storage medium 904 to implement the above-mentioned Figure 5 as well as Figure 6 In a specific implementation, the computer instructions in the computer-readable storage medium 904 are loaded by the processor 901 and execute the following steps:
[0139] Determining a data access request, wherein the data access request includes data access information and database location information;
[0140] Sending a data access request to a proxy server, wherein the data access request is used to instruct the proxy server to access the target database according to the database address of the target database to obtain a data access result, wherein the database address of the target database is obtained by parsing the data access request, and the database address of the target database is any one of the database addresses of at least one database, and the at least one database is a database authorized to the proxy server;
[0141] The data access result returned by the proxy server is received.
[0142] In a possible implementation, when the computer instructions in the computer-readable storage medium 904 are loaded and executed by the processor 901 to determine the data access request, they are specifically used to perform the following steps:
[0143] Determine data access information;
[0144] Determine, from a database location list according to the data access information, database location information that matches the data access information;
[0145] The data access information and the database location information are encapsulated and processed through a database communication protocol to obtain a data access request.
[0146] In a possible implementation, the computer instructions in the computer-readable storage medium 904 are loaded and executed by the processor 901 to encapsulate the data access information and the database location information through the database communication protocol, and when a data access request is obtained, the computer instructions are specifically used to perform the following steps: the business server generates a database query statement using the database communication protocol and the data access information;
[0147] Setting the database location information as annotation information of the database query statement through the database communication protocol;
[0148] The database query statement and the annotation information of the database query statement are encapsulated and processed through the database communication protocol to obtain a data access request.
[0149] When the computer device is a proxy server 102, the processor 901 may load and execute one or more computer instructions stored in the computer-readable storage medium 904 to implement the above-mentioned Figure 2 as well as Figure 6 In a specific implementation, the computer instructions in the computer-readable storage medium 904 are loaded by the processor 901 and execute the following steps:
[0150] Receiving a data access request sent by a business server, wherein the data access request includes data access information and database location information;
[0151] Parsing the data access request to obtain a database address of a target database corresponding to the database location information, wherein the database address of the target database is any one of database addresses of at least one database, and the at least one database is a database authorized to the proxy server;
[0152] Determine a database connection pool corresponding to the target database according to a database address of the target database;
[0153] The target database is accessed by using the database connection pool, a data access result corresponding to the data access information is obtained, and the data access result is returned to the business server.
[0154] In a possible implementation, the computer instructions in the computer-readable storage medium 904 are loaded and executed by the processor 901 to parse the data access request, and when the database address of the target database corresponding to the database location information is obtained, the computer instructions are specifically used to perform the following steps:
[0155] Parsing the data access request through a database communication protocol to obtain character information corresponding to the data access request;
[0156] A database address of a target database matching the database location information is obtained from the character information corresponding to the data access request.
[0157] In a possible implementation, the data access request includes a database query statement and annotation information of the database query statement, the database query statement includes data access information, and the annotation information includes database location information.
[0158] In a possible implementation, when the computer instructions in the computer-readable storage medium 904 are loaded and executed by the processor 901 to determine the database connection pool corresponding to the target database according to the database address of the target database, the computer instructions are specifically used to perform the following steps:
[0159] Querying a database connection pool corresponding to the target database according to the database address of the target database;
[0160] If there is a database connection pool corresponding to the target database, obtain the database connection pool corresponding to the target database;
[0161] If the database connection pool corresponding to the target database does not exist, a database connection pool corresponding to the target database is created according to the target database address.
[0162] In a possible implementation, the computer instructions in the computer-readable storage medium 904 are loaded and executed by the processor 901 to access the target database using the database connection pool, and when a data access result corresponding to the data access information is obtained, the computer instructions are specifically used to perform the following steps:
[0163] Determine a database connection used by the business server from a database connection pool corresponding to the target database, wherein the database connection includes one of a newly created connection and an idle connection;
[0164] The data access result corresponding to the data access information is obtained from the target database using the database connection used by the business server.
[0165] In an embodiment of the present application, the business server is connected to a designated proxy server and sends a data access request to the proxy server. After receiving the data access request sent by the business server, the proxy server parses the data access request to obtain the database address of the target database, and then determines the database connection pool corresponding to the target database according to the database address of the target database, and uses the database connection pool to access the target database to obtain the data access result corresponding to the data access information. Finally, the proxy server returns the data access result directly to the business server. During the data access process, the business server only needs to connect to the designated proxy server, and then the data access process for different databases is centrally managed and processed by the designated proxy server to obtain the data access result. This can reduce the management cost of the business server and improve the data access capability.
[0166] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data access method provided in the above-mentioned various optional modes.
[0167] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0168] In the several embodiments provided in this application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, and the division of the modules described above is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0169] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data access method, characterized in that: The method comprises: The proxy server receives a data access request sent by the business server, wherein the data access request includes data access information and database location information; The proxy server parses the data access request to obtain a database address of a target database corresponding to the database location information, wherein the database address of the target database is any one of database addresses of at least one database, and the at least one database is a database authorized to the proxy server; The proxy server determines a database connection pool corresponding to the target database according to a database address of the target database; The proxy server uses the database connection pool to access the target database, obtains a data access result corresponding to the data access information, and returns the data access result to the business server.
2. The method according to claim 1, characterized in that The proxy server parses the data access request to obtain a database address of a target database corresponding to the database location information, including: The proxy server parses the data access request through a database communication protocol to obtain character information corresponding to the data access request; The proxy server obtains a database address of a target database matching the database location information from the character information corresponding to the data access request.
3. The method according to claim 1, characterized in that The data access request includes a database query statement and annotation information of the database query statement, the database query statement includes data access information, and the annotation information includes database location information.
4. The method according to claim 1, characterized in that The proxy server determines a database connection pool corresponding to the target database according to a database address of the target database, including: The proxy server queries a database connection pool corresponding to the target database according to the database address of the target database; If there is a database connection pool corresponding to the target database, the proxy server obtains the database connection pool corresponding to the target database; If the database connection pool corresponding to the target database does not exist, the proxy server creates a database connection pool corresponding to the target database according to the target database address.
5. The method according to any one of claims 1 to 4, characterized in that: The proxy server uses the database connection pool to access the target database, and obtains a data access result corresponding to the data access information, including: The proxy server determines a database connection used by the business server from a database connection pool corresponding to the target database, wherein the database connection includes one of a newly created connection and an idle connection; The proxy server uses the database connection used by the business server to obtain the data access result corresponding to the data access information from the target database.
6. A data access method, characterized in that: The method comprises: The business server determines a data access request, where the data access request includes data access information and database location information; The business server sends a data access request to the proxy server, wherein the data access request is used to instruct the proxy server to access the target database according to the database address of the target database to obtain a data access result, wherein the database address of the target database is obtained by parsing the data access request, and the database address of the target database is any one of the database addresses of at least one database, and the at least one database is a database authorized to the proxy server; The business server receives the data access result returned by the proxy server.
7. The method according to claim 6, characterized in that The business server determines the data access request, including: The business server determines data access information; The business server determines, from a database location list according to the data access information, database location information that matches the data access information; The business server encapsulates the data access information and the database location information through a database communication protocol to obtain a data access request.
8. The method according to claim 7, characterized in that The business server encapsulates the data access information and the database location information through a database communication protocol to obtain a data access request, including: The business server generates a database query statement using the database communication protocol and the data access information; The business server sets the database location information as annotation information of the database query statement through the database communication protocol; The business server encapsulates the database query statement and the annotation information of the database query statement through the database communication protocol to obtain a data access request.
9. A data access device, characterized in that: The device comprises: A transceiver unit, configured to receive a data access request sent by a business server, wherein the data access request includes data access information and database location information; a processing unit, configured to parse the data access request to obtain a database address of a target database corresponding to the database location information, wherein the database address of the target database is any one of database addresses of at least one database, and the at least one database is a database authorized to the proxy server; A determination unit, configured to determine a database connection pool corresponding to the target database according to a database address of the target database; The transceiver unit is further used to access the target database using the database connection pool, obtain a data access result corresponding to the data access information, and return the data access result to the business server.
10. A data access device, characterized in that: The device comprises: a determining unit, configured to determine a data access request, wherein the data access request includes data access information and database location information; a transceiver unit, configured to send a data access request to a proxy server, wherein the data access request is used to instruct the proxy server to access the target database according to the database address of the target database to obtain a data access result, wherein the database address of the target database is obtained by parsing the data access request, and the database address of the target database is any one of the database addresses of at least one database, and the at least one database is a database authorized to the proxy server; The transceiver unit is further used to receive the data access result returned by the proxy server.
11. A computer device, characterized in that: The computer device comprises: a processor adapted to implement one or more computer programs; and, A computer storage medium storing one or more computer programs, wherein the one or more computer programs are suitable for being loaded by the processor and executing the data access method as described in any one of claims 1-5 or 6-8.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores one or more computer programs, and the one or more computer programs are suitable for being loaded by a processor and executing the data access method according to any one of claims 1-5 or 6-8.
13. A computer program product, characterized in that The computer program product includes a computer program, which is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the data access method as described in any one of claims 1-5 or 6-8.
Citation Information
Patent Citations
Distributed-type database access method and system
CN102033912A
Database access method and device, computer equipment and storage medium
CN112866348A
Method and system for obtaining user information accessing SQL database and storage medium
CN114547697A