A data query method, device and system

CN117421327BActive Publication Date: 2026-10-30SHANGHAI ZHONG YUAN NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311323591.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-12
Publication Date
2026-10-30
Estimated Expiration
2043-10-12

AI Technical Summary

Technical Problem

[0003]在实践中发现,由于数据库的类型非常多样、复杂,而现有的数据库管理控制方式需要针对不同类型的数据库,针对性维护对应的查询语句,从而导致数据库的维护和升级复杂度较高

Benefits of technology

[0044]通过本申请,能够通过业务代理容器,处理不同数据库、不同SQL、不同返回参数类型的数据库处理请求,实现数据库访问和管理的标准化、统一化处理,从而能够简化数据库的维护和升级,有助于降低数据库维护和升级的复杂度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117421327B_ABST
    Figure CN117421327B_ABST
Patent Text Reader

Abstract

The application relates to a data query method, device and system, and belongs to the technical field of data processing. The application obtains a formatted query statement for querying data sent by a client device; wherein the formatted query statement at least comprises a database name to be queried; a business proxy container is used to analyze the formatted query statement to obtain the database name; and the business proxy container is used to forward the formatted query statement to a target database corresponding to the database name, so that the formatted query statement is executed in the target database to obtain a database processing result. The application can help reduce the complexity of database maintenance and upgrading.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of data processing technology, specifically relating to a data query method, apparatus, and system. Background Technology

[0002] Currently, in existing distributed systems, different business services may use different types of databases. Different query statements are needed to manage and control the database for different types of databases.

[0003] In practice, it has been found that due to the wide variety and complexity of database types, and the fact that existing database management and control methods require the maintenance of specific query statements for different types of databases, the maintenance and upgrade of databases are quite complex.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] Therefore, this application provides a data query method, apparatus, and system that helps reduce the complexity of database maintenance and upgrades.

[0006] To achieve the above objectives, this application adopts the following technical solution:

[0007] Firstly, this application provides a data query method applied to a business server, the method comprising:

[0008] Obtain a formatted query statement sent by the client device for querying data; wherein the formatted query statement includes at least: the name of the database to be queried;

[0009] The database name is obtained by parsing the formatted query statement through the business proxy container;

[0010] The business proxy container forwards the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result.

[0011] Furthermore, the formatted query statement also includes: a return parameter type; and, through the business proxy container, forwarding the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result, including:

[0012] The business proxy container forwards the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result corresponding to the return parameter type.

[0013] Furthermore, the database processing result is determined based on the following steps:

[0014] Receive the initial query result returned by the database server where the target database is deployed; wherein, the initial query result is the query result obtained by executing the formatted query statement in the target database;

[0015] Based on the returned parameter type, the initial query result is serialized to obtain the database processing result.

[0016] Furthermore, the formatted query statement is obtained by the client device through format conversion based on the initial query statement.

[0017] Furthermore, the formatted query statement is parsed through the business proxy container to obtain the database name, including:

[0018] The annotation information corresponding to the formatted query statement is determined in the database access class through the business proxy container;

[0019] The annotation information is parsed to obtain the database name.

[0020] Furthermore, the method also includes:

[0021] The JDK dynamic proxy is used to execute extended code for the database access class; wherein the extended code is used at least to record data query logs in the database access class.

[0022] Furthermore, the method also includes:

[0023] In the preset configuration center, configure the name information corresponding to each database; wherein, the name information includes common name information and alias information;

[0024] Before forwarding the formatted query statement to the target database corresponding to the database name through the business proxy container, the method further includes:

[0025] The database name is matched with the name information corresponding to each pre-configured database, and the target database that matches the database name is determined from each pre-configured database.

[0026] Furthermore, after configuring the name information corresponding to each database in the preset configuration center, the method further includes:

[0027] The business proxy container reads the name information corresponding to each pre-configured database from the preset configuration center.

[0028] Based on the name information, each pre-configured database is connected to at least one database connection pool.

[0029] Secondly, this application provides a data query device, the device comprising:

[0030] The statement acquisition unit is used to acquire a formatted query statement sent by the client device for querying data; wherein the formatted query statement includes at least: the name of the database to be queried;

[0031] The name determination unit is used to parse the formatted query statement through the business proxy container to obtain the database name;

[0032] The data query unit is used to forward the formatted query statement to the target database corresponding to the database name through the business proxy container, so as to execute the formatted query statement in the target database and obtain the database processing result.

[0033] Thirdly, this application provides a data query system, comprising: a client device, a business server, and at least one data query server; wherein the client device is used to deploy a main application, the business server is used to deploy branch services corresponding to the main application, and the at least one data query server is used to deploy at least one database; the client device establishes a communication connection with the business server, and the business server establishes a communication connection with the at least one data query server; wherein the business server is used to execute the method as described in the first aspect.

[0034] Fourthly, this application provides a data query system, comprising: a business server, at least one container group, a business proxy container, and a business service container; wherein the at least one container group is deployed on the business server, and the business proxy container and the business service container are deployed in the at least one container group; wherein the business proxy container is used to provide proxy services during the data query process, the business service container is used to provide branch services corresponding to the main application, and the business server is used to execute the method as described in the first aspect.

[0035] Furthermore, the business proxy container and the business service container are deployed in the same container group.

[0036] Furthermore, the business proxy container and the business service container are deployed in different container groups.

[0037] Fifthly, this application provides an electronic device, comprising:

[0038] At least one processor; and

[0039] A memory communicatively connected to the at least one processor; wherein,

[0040] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect.

[0041] In a sixth aspect, this application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to perform the method described in the first aspect.

[0042] In a seventh aspect, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.

[0043] The application employs the above technical solution and has at least the following beneficial effects:

[0044] This application enables the use of a business proxy container to handle database processing requests from different databases, different SQL queries, and different return parameter types, thereby achieving standardized and unified processing of database access and management. This simplifies database maintenance and upgrades and helps reduce the complexity of database maintenance and upgrades.

[0045] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 This is a flowchart illustrating a data query method according to an exemplary embodiment;

[0048] Figure 2 This is a schematic diagram illustrating the architecture of a data query method according to an exemplary embodiment;

[0049] Figure 3 This is a block diagram illustrating a data query device according to an exemplary embodiment;

[0050] Figure 4 This is a block diagram illustrating a data query system according to an exemplary embodiment;

[0051] Figure 5 This is a block diagram illustrating a data query system according to an exemplary embodiment;

[0052] Figure 6 This is a block diagram illustrating the structure of an electronic device according to an exemplary embodiment. Detailed Implementation

[0053] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be described in detail below. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other implementation methods obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0054] Please see Figure 1 , Figure 1 This is a flowchart illustrating a data query method according to an exemplary embodiment, the data query method comprising the following steps:

[0055] Step S101: Obtain a formatted query statement sent by the client device for querying data; wherein the formatted query statement includes at least: the name of the database to be queried.

[0056] In this embodiment, the executing entity can be a business server. The client device is used to deploy the main application, and the business server is used to deploy branch services corresponding to the main application. A communication connection is established between the client device and the business server. Then, the executing entity can receive formatted query statements sent by the client device for retrieving data.

[0057] The client device can format and transform the initial query statement to obtain a standardized formatted query statement, which is then sent to the business server. The initial query statement can contain various types of query statements; based on the formatting transformation, different types of query statements can be processed uniformly. This allows the business proxy container to handle database processing requests for different types of query statements, achieving unified database access and management.

[0058] Step S102: Parse the formatted query statement through the business proxy container to obtain the database name.

[0059] In this embodiment, the business proxy container is typically a sidecar container. The sidecar container can parse the formatted query statement based on the data access layer interface to obtain the database name. During architecture construction, it is preferable to deploy the sidecar to the Pod corresponding to the business service; the sidecar provides the data access layer interface. The sidecar mode is a deployment mode where one container (called the main container) runs alongside another container (called the sidecar container). The main container and the sidecar container can share network and storage, and communicate by sharing environment variables and files.

[0060] In Kubernetes (K8s), a Pod (container group) is the smallest deployable unit. A container group represents a single running instance of an application in Kubernetes, which may consist of a single container or several tightly coupled containers.

[0061] Specifically, sidecars can be deployed to the same Pod as the business service using Kubernetes Deployments. A Deployment is a controller in Kubernetes used to manage deployments.

[0062] The sidecar provides a data access layer interface, which is used to query the target database for data from the specified data source (the target database corresponding to the database name) using standard SQL (formatted query statement) and return the data to the business service. This enables the sidecar to fully proxy the data interaction between the business service and the database, thereby enabling the business proxy container to handle database processing requests from different databases and different SQL statements.

[0063] Specifically, the business service can pass standard SQL and a specified data source to the sidecar through the data access layer interface. The sidecar, based on the received standard SQL and specified data source, queries the database for data from the specified data source and returns it to the business service. The generation of the standard SQL and the specification of the data source can be achieved by developers writing SQL (Structured Query Language) or JPA (Java Persistence API) to provide maximum flexibility to the client. The standard SQL is the formatted query statement mentioned above. Preferably, the standard SQL can be generated by converting the format of the initial query statement written by the developer.

[0064] Step S103: The formatted query statement is forwarded to the target database corresponding to the database name through the business proxy container, so as to execute the formatted query statement in the target database and obtain the database processing result.

[0065] In this embodiment, after the sidecar resolves the database name, it can find the corresponding database connection pool (Druid) based on the database name and connect to the corresponding target database through the database connection pool. Furthermore, the sidecar can also parse the formatted query statement through the SQL Parser module of the database connection pool (Druid) to map the parsed formatted query statement to the target query statement in the corresponding database, so as to execute the target query statement in the target database and obtain the database processing result. The target query statement can include, but is not limited to, ES (Elasticsearch, a distributed search and analysis engine) query statements, MONGO (a database based on distributed file storage), etc., and this embodiment does not limit it.

[0066] In this embodiment, after the sidecar obtains the database processing result, it can return the database processing result to the business service based on the data access layer interface.

[0067] Furthermore, the formatted query statement also includes: a return parameter type; and, through the business proxy container, forwarding the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result, including:

[0068] The business proxy container forwards the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result corresponding to the return parameter type.

[0069] In this embodiment, after obtaining the target database connection, the sidecar can execute the transformed target query statement to obtain the database processing result corresponding to the return parameter type, thereby enabling the processing of database processing requests of different databases, different SQL, and different return parameter types through the business proxy container.

[0070] Furthermore, the database processing result is specifically determined based on the following steps:

[0071] Receive the initial query result returned by the database server where the target database is deployed; wherein, the initial query result is the query result obtained by executing the formatted query statement in the target database;

[0072] Based on the returned parameter type, the initial query result is serialized to obtain the database processing result.

[0073] In this embodiment, after establishing a connection with the target database, the sidecar can execute the target query statement matching the formatted query statement in the target database to obtain initial query results. Then, based on the return parameter type, the initial query results are serialized to obtain a serialized result, which is then returned to the business service as the database processing result.

[0074] The executing entity obtains the aforementioned return parameter types from the request parameters of the data access layer interface. Then, using the default camelCase naming convention for class variables, the column names returned by the database in the initial query results are bound to the class variables. For example, if the data field `user_email` is `xxx@xx.com`, and the class variable is `userEmail`, then `user_email` is bound to `userEmail`. Using this method, all columns are bound to the class variables, generating a `JsonObject`. This `JsonObject` is then converted into a string and returned to the business service. The string converted from the `JsonObject` is the serialized result described above. Many JSON frameworks are available, including but not limited to FastJson, Gson, and Jackson.

[0075] Furthermore, the formatted query statement is obtained by the client device through format conversion based on the initial query statement.

[0076] Furthermore, the formatted query statement is parsed through the business proxy container to obtain the database name, including:

[0077] The annotation information corresponding to the formatted query statement is determined in the database access class through the business proxy container;

[0078] The annotation information is parsed to obtain the database name.

[0079] In this embodiment, annotation information can be pre-added to the relevant classes that access the target database. For example, add the annotation @SidecarDataSource(name=xxx) to specify the name of the database to be accessed, and add the annotation @SidecarQuery(sql=xxx,type=sql / jpa) to the database access scheme to specify the SQL and the return parameter type.

[0080] Furthermore, through the data access layer interface, annotation information can be read and parsed to obtain the database name. The SQL statement and return parameter types can also be obtained. The database name, SQL statement, and return parameter types constitute the obtained request parameters.

[0081] Furthermore, if the `type` attribute in the `@SidecarQuery` annotation is `sql`, then retrieving the `sql` attribute will yield the standard SQL query statement. If `type` is `jpa`, then the native SQL statement can be parsed using JPA naming conventions and used as the target query statement.

[0082] Furthermore, the method also includes:

[0083] The JDK dynamic proxy is used to execute extended code for the database access class; wherein the extended code is used at least to record data query logs in the database access class.

[0084] In this embodiment, JDK dynamic proxies can be used to enhance the database access class.

[0085] This approach leverages JDK dynamic proxies to execute corresponding extension code, which can be customized by the user, simplifying database access capabilities for business services. Furthermore, during the enhancement process, aspects can be defined on the traditional database access class, and subsequent enhancements are implemented based on these aspects. After defining the aspect, the SQL query, database name, and return parameter types can be retrieved. Then, the sidecar is called to obtain the returned result (the database processing result mentioned above). This method enables enhanced processing of the database access class, replacing the traditional database access approach.

[0086] Furthermore, the method also includes:

[0087] In the preset configuration center, configure the name information corresponding to each database; wherein, the name information includes common name information and alias information;

[0088] Before forwarding the formatted query statement to the target database corresponding to the database name through the business proxy container, the method further includes:

[0089] The database name is matched with the name information corresponding to each pre-configured database, and the target database that matches the database name is determined from each pre-configured database.

[0090] In this embodiment, the executing entity can configure the data source and its corresponding alias information to a preset configuration center, such as the Apollo Configuration Center. The data source is a database connection pool, and each database connection pool has corresponding common name and alias information. When it is necessary to determine the target database, the database name in the formatted query statement can be matched with the pre-configured name information of each database to find the target database that matches the database name. This process considers both common names and aliases during the matching process, resulting in a higher degree of matching accuracy.

[0091] Furthermore, after configuring the name information corresponding to each database in the preset configuration center, the method further includes:

[0092] The business proxy container reads the name information corresponding to each pre-configured database from the preset configuration center.

[0093] Based on the name information, each pre-configured database is connected to at least one database connection pool.

[0094] In this embodiment, the sidecar can read database configuration information from the preset configuration center and initialize the database connection pool based on this information. Then, based on the initialized database connection pool, it connects to the database connection pool corresponding to the database name, and finally connects to the target database. During initialization, the database connection pool can create a certain number of database connections and place them in the pool.

[0095] In this embodiment, preferably, Kubernetes Deployment enables the deployment of business services in different containers within the same Pod. Business services and sidecars within the same Pod share the same network, thereby achieving unified access and management of the database through the sidecar.

[0096] Please see Figure 2 , Figure 2 This is a schematic diagram illustrating the architecture of a data query method according to an exemplary embodiment, such as... Figure 2As shown, business services and sidecars are deployed within the same Pod. The business services are deployed in different containers within the same Pod (not shown). The business services can enhance database access classes based on JDK dynamic proxies, simplifying database access for the business services. Specifically, the business services can intercept and call the data access layer interface provided by the sidecar, passing request parameters (database name, SQL, return parameter type) to the sidecar. Then, the sidecar, based on the database name, reads the corresponding alias and database connection configuration from a pre-defined configuration center. Based on the database name, alias, and database connection configuration, it initializes the database connection pool and connects to the target database (ES, MySQL, MongoDB, etc.) through the initialized connection pool. Afterwards, the corresponding target query statement can be executed in the target database to obtain the database processing result. Finally, based on the data access layer interface, the database processing result is returned to the business service. This sidecar-based database access architecture standardizes and unifies database access and management. Database configuration and version management can be centralized in the sidecar, simplifying database maintenance and upgrade processes. Furthermore, based on JDK dynamic proxies, the ability to access databases for business services is simplified.

[0097] This application enables the processing of database requests with different databases, different SQL statements, and different return parameter types through the data access layer interface provided by the sidecar, achieving standardized and unified processing of database access and management. This simplifies database maintenance and upgrades, and helps reduce the complexity of database maintenance and upgrades.

[0098] Please see Figure 3 , Figure 3 This is a block diagram illustrating a data query device 3 according to an exemplary embodiment. The data query device 3 includes:

[0099] The statement acquisition unit 301 is used to acquire a formatted query statement sent by the client device for querying data; wherein, the formatted query statement includes at least: the name of the database to be queried;

[0100] The name determination unit 302 is used to parse the formatted query statement through the business proxy container to obtain the database name;

[0101] The data query unit 303 is used to forward the formatted query statement to the target database corresponding to the database name through the business proxy container, so as to execute the formatted query statement in the target database and obtain the database processing result.

[0102] This application enables the use of a business proxy container to handle database processing requests from different databases, different SQL queries, and different return parameter types, thereby achieving standardized and unified processing of database access and management. This simplifies database maintenance and upgrades and helps reduce the complexity of database maintenance and upgrades.

[0103] Regarding the data query device 3 in the above embodiments, the specific methods by which each module performs operations have been described in detail in the embodiments of the related methods described above, and will not be elaborated here.

[0104] Please see Figure 4 , Figure 4 This is a block diagram illustrating a data query system according to an exemplary embodiment. The data query system includes: a client device, a business server, and at least one data query server. The client device is used to deploy a main application, the business server is used to deploy branch services corresponding to the main application, and the at least one data query server is used to deploy at least one database. The client device establishes a communication connection with the business server, and the business server establishes a communication connection with the at least one data query server. The business server is used for the aforementioned data query method. Specifically, when the client device (main application) calls the business server to implement the corresponding branch service, the business server can obtain the corresponding database processing result by parsing the formatted query statement through a business proxy container based on the aforementioned data query method. Then, the business server can return the database processing result to the client device, completing the entire branch service call.

[0105] Please see Figure 5 , Figure 5 This is a block diagram illustrating a data query system according to an exemplary embodiment. The data query system includes: a business server, at least one container group, a business proxy container, and a business service container; wherein, the at least one container group is deployed on the business server, and the business proxy container and the business service container are deployed in the at least one container group; wherein, the business proxy container is used to provide proxy services during the data query process, the business service container is used to provide branch services corresponding to the main application, and the business server is used to execute the above-described data query method.

[0106] Furthermore, the business proxy container and the business service container are deployed in the same container group.

[0107] Furthermore, the business proxy container and the business service container are deployed in different container groups.

[0108] When deployed within the same pod, the intermediate data transfer workload is reduced compared to deploying them in different pods. Therefore, it is preferable to deploy the business proxy container and the business service container in the same container group.

[0109] Please see Figure 6 , Figure 6 This is a block diagram illustrating an electronic device 6 according to an exemplary embodiment. The electronic device 6 includes:

[0110] At least one processor 61; and

[0111] Memory 62 communicatively connected to the at least one processor 61; wherein,

[0112] The memory 62 stores instructions that can be executed by the at least one processor 61, which, when executed by the at least one processor 61, enable the at least one processor 61 to perform the aforementioned related data query method.

[0113] In practical applications, electronic device 6 can be a business server. Regarding the electronic device 6 in the above embodiments, the specific way in which its processor 61 executes the program in memory 62 has been described in detail in the embodiments related to the method, and will not be elaborated here.

[0114] In addition, this application also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the above-mentioned related data query method.

[0115] The storage medium may be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium may also include combinations of the above types of memory.

[0116] In addition, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-mentioned data query method.

[0117] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.

[0118] It should be noted that in the description of this application, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this application, unless otherwise stated, "multiple" or "more" means at least two.

[0119] It should be understood that when an element is referred to as "fixed to" or "set on" another element, it may be directly on the other element or may have an intervening element present at the same time; when an element is referred to as "connected to" another element, it may be directly connected to the other element or may have an intervening element present at the same time. In addition, the term "connected" as used herein may include wireless connections; the word "and / or" as used includes any unit and all combinations of one or more of the associated listed items.

[0120] Any process or method description in the flowchart or otherwise herein can be understood as: representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as should be understood by those skilled in the art to which embodiments of this application pertain.

[0121] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0122] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium. When executed, the program includes one or a combination of the steps of the method embodiments.

[0123] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0124] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.

[0125] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0126] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.

Claims

1. A data query method, characterized in that, Applied to a business server, the method includes: Obtain a formatted query statement sent by the client device for querying data; wherein the formatted query statement includes at least: the name of the database to be queried; The business proxy container parses the formatted query statement to obtain the database name, including: determining the annotation information corresponding to the formatted query statement in the database access class through the business proxy container; parsing the annotation information to obtain the database name; wherein the business proxy container and the business server are deployed in the same container group; Through JDK dynamic proxy, extended code for the database access class is executed; wherein, the extended code is at least used to record data query logs in the database access class, and to obtain the formatted query statement and the database name in the extended code, and pass the formatted query statement and the database name to the business proxy container; In the preset configuration center, configure the name information corresponding to each database; wherein, the name information includes common name information and alias information; The database name is matched with the name information corresponding to each pre-configured database, and the target database that matches the database name is determined from each pre-configured database. The business proxy container reads the name information corresponding to each pre-configured database from the preset configuration center; based on the name information, it connects each pre-configured database to at least one database connection pool. The business proxy container forwards the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result.

2. The method according to claim 1, characterized in that, The formatted query statement also includes: a return parameter type; and, through the business proxy container, forwarding the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result, including: The business proxy container forwards the formatted query statement to the target database corresponding to the database name, so as to execute the formatted query statement in the target database and obtain the database processing result corresponding to the return parameter type.

3. The method according to claim 2, characterized in that, The database processing result is determined based on the following steps: Receive the initial query result returned by the database server where the target database is deployed; wherein, the initial query result is the query result obtained by executing the formatted query statement in the target database; Based on the returned parameter type, the initial query result is serialized to obtain the database processing result.

4. The method according to claim 1, characterized in that, The formatted query statement is obtained by the client device through format conversion based on the initial query statement.

5. A data query device, characterized in that, The device, applied to a business server, includes: The statement acquisition unit is used to acquire a formatted query statement sent by the client device for querying data; wherein the formatted query statement includes at least: the name of the database to be queried; The name determination unit is used to parse the formatted query statement through a business proxy container to obtain the database name, including: determining the annotation information corresponding to the formatted query statement in the database access class through the business proxy container; parsing the annotation information to obtain the database name; wherein the business proxy container and the business server are deployed in the same container group; A data query unit is configured to execute extended code for the database access class via JDK dynamic proxy. This extended code at least records data query logs within the database access class and retrieves the formatted query statement and the database name. It then passes the formatted query statement and the database name to the business proxy container. Furthermore, it configures name information for each database in a preset configuration center, including common name information and alias information. The unit matches the database name with the pre-configured name information for each database, determining a target database matching the database name from the pre-configured databases. The business proxy container reads the pre-configured name information for each database from the preset configuration center and connects the pre-configured databases to at least one database connection pool based on the name information. Finally, the business proxy container forwards the formatted query statement to the target database corresponding to the database name, executing the formatted query statement in the target database to obtain the database processing result.

6. A data query system, characterized in that, include: The system comprises a client device, a business server, and at least one data query server; wherein the client device is used to deploy a main application, the business server is used to deploy a branch service corresponding to the main application, and the at least one data query server is used to deploy at least one database; the client device establishes a communication connection with the business server, and the business server establishes a communication connection with the at least one data query server; wherein the business server is used to perform the method as described in any one of claims 1 to 4.

7. A data query system, characterized in that, include: The system comprises a business server, at least one container group, a business proxy container, and a business service container; wherein the at least one container group is deployed on the business server, and the business proxy container and the business service container are deployed in the at least one container group; wherein the business proxy container is used to provide proxy services during data querying, the business service container is used to provide branch services corresponding to the main application, and the business server is used to execute the method as described in any one of claims 1 to 4.

8. The system according to claim 7, characterized in that, The business proxy container and the business service container are deployed in the same container group.

Citation Information

Patent Citations

  • Multi-database data processing method and related equipment

    CN116827614A