Database interface routing methods, devices, computer equipment, and storage media

By using an adaptive interface routing engine to perform intelligent routing when database types are inconsistent, the risks to business operations and compatibility issues caused by database switching are resolved, enabling lossless migration and efficient operation.

CN115630110BActive Publication Date: 2026-05-26PING AN BANK CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PING AN BANK CO LTD
Filing Date
2022-11-04
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In a single platform system, different business types rely on different database types, resulting in a large and highly uncertain task of switching database types. Existing technologies pose risks of traffic loss and business operation, affecting the compatibility of the platform system.

Method used

This paper provides a database interface routing method. By obtaining the database type of the current and next business, an interface routing instruction is sent. The method uses a pre-annotated adaptive interface routing engine to find the matching database interface and performs lossless switching according to the routing rules, thereby realizing intelligent routing of database interfaces.

Benefits of technology

It enables seamless database switching and intelligent interface routing, ensuring secure and lossless data migration without affecting current business operations, thus improving the compatibility and operational efficiency of businesses on the same platform.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115630110B_ABST
    Figure CN115630110B_ABST
Patent Text Reader

Abstract

This application provides a database interface routing method, apparatus, computer device, and storage medium. The method obtains the database type of the current service and the database type of the next service to be operated on. If the database type of the current service and the database type of the next service are inconsistent, it sends an interface routing instruction for the source database corresponding to the current service. It obtains a pre-annotated adaptive interface routing engine, searches for a database interface matching the target database type from the adaptive interface routing engine as the target interface, and routes the source database to the target interface according to the target routing rules to operate the next service. This achieves lossless database switching and intelligent routing of database interfaces, ensuring secure and lossless migration of data between different database types without affecting the current service, and improving the compatibility of services on the same platform and the efficiency and security of business operations within the platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a database interface routing method, apparatus, computer device, and storage medium. Background Technology

[0002] Today's single-platform systems encompass an increasing number of business types and functional modules. Because different businesses within the same platform rely on different database types, switching between database types for different business types or functional modules becomes a massive and unpredictable task. Currently, one approach is to reinvent the wheel to implement database sharding logic for different business types, which requires specialized knowledge from developers and adds unnecessary workload. Another approach is to manually switch all businesses, i.e., offline synchronization of the database type to be switched and then restarting the server to complete the business operation. This inevitably leads to traffic loss and poses certain risks to business operations, reducing the platform's compatibility and affecting the operation of other business or functional modules within the platform. Therefore, it is necessary to provide a secure, lossless database switching solution that does not affect existing business operations. Summary of the Invention

[0003] Therefore, it is necessary to provide an interface routing method, device, computer equipment, and storage medium for databases that can be used in fintech or other related fields to address the aforementioned technical problems, in order to solve the technical issues of business operation risks caused by database switching and incompatibility of business on the same platform.

[0004] On the one hand, this application provides a database interface routing method, the method comprising:

[0005] Get the database type of the current business and get the database type of the next business to be operated on;

[0006] If the database type of the current service is inconsistent with the database type of the next service, an interface routing instruction for the source database corresponding to the current service is sent. The interface routing instruction includes the target database type and target routing rule corresponding to the next service.

[0007] Obtain a pre-annotated adaptive interface routing engine, which includes database interfaces corresponding to multiple different types of databases;

[0008] The adaptive interface routing engine searches for a database interface that matches the target database type as the target interface;

[0009] The source database is routed to the target interface according to the target routing rules in order to operate the next service.

[0010] On one hand, this application provides a database interface routing device, the device comprising:

[0011] The first acquisition module is used to acquire the database type of the current business and the database type of the next business to be operated on.

[0012] The sending module is used to send an interface routing instruction for the source database corresponding to the current service when the database type of the current service is inconsistent with the database type of the next service. The interface routing instruction includes the target database type and target routing rules corresponding to the next service.

[0013] The second acquisition module is used to acquire the pre-annotated adaptive interface routing engine, which includes database interfaces corresponding to multiple different types of databases.

[0014] The lookup module is used to find a database interface that matches the target database type from the adaptive interface routing engine as the target interface;

[0015] The routing module is used to route the source database to the target interface according to the target routing rules in order to operate the next service.

[0016] On one hand, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps in the interface routing method of the aforementioned database.

[0017] On the one hand, this application provides a computer-readable medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps in the interface routing method of the aforementioned database.

[0018] This application provides a database interface routing method. By obtaining the database type of the current service and the database type of the next service to be operated on, and when the database types of the current and next services are inconsistent, an interface routing instruction for the source database corresponding to the current service is sent. The interface routing instruction includes the target database type and target routing rules corresponding to the next service. A pre-annotated adaptive interface routing engine is obtained, which includes multiple database interfaces corresponding to different database types. The database interface matching the target database type is found from the adaptive interface routing engine as the target interface. The source database is routed to the target interface according to the target routing rules to operate the next service. This achieves lossless database switching and intelligent routing of database interfaces. Using this application, secure and lossless data migration between different database types is guaranteed, without affecting the current service, improving the compatibility of services on the same platform and the efficiency and security of business operations within the platform. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention 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 the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] in:

[0021] Figure 1 This is a schematic diagram illustrating an application scenario of the database interface routing method in one embodiment;

[0022] Figure 2 This is a flowchart of a database interface routing method in one embodiment;

[0023] Figure 3 This is a structural block diagram of a database interface routing device in one embodiment;

[0024] Figure 4 This is a structural block diagram of a computer device in one embodiment. Detailed Implementation

[0025] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0026] The database interface routing method provided in this application can be applied to, for example... Figure 1 In this application environment, terminal devices communicate with the server via a network. These terminal devices can be, but are not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be a standalone server or a server cluster consisting of multiple servers.

[0027] System framework 100 may include terminal devices 101, 102, and 103, a network 104, and a server 105. The network is used as a medium to provide a communication link between the terminal devices and the server. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0028] Users can use terminal devices to interact with the server over the network to receive or send messages, etc.

[0029] Terminal devices 101, 102, and 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, e-book readers, MP3 players (Moving Picture Eperts Group Audio Layer III), MP4 players (Moving Picture Eperts Group Audio Layer IV), laptops, and desktop computers, etc.

[0030] Server 105 can be a server that provides various services, such as a backend server that supports the pages displayed on terminal devices 101, 102, and 103.

[0031] It should be noted that the database interface routing method provided in this embodiment of the invention is executed by the server, and correspondingly, the database interface routing device is set in the server.

[0032] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown in this embodiment is merely illustrative. Depending on the implementation needs, there can be any number of terminal devices, networks, and servers. The terminal devices in this embodiment can specifically correspond to application systems in actual production.

[0033] like Figure 2 As shown, in one embodiment, a database interface routing method is provided. This database interface routing method can be applied to both terminals and servers; this embodiment illustrates its application to a server. The database interface routing method specifically includes the following steps:

[0034] Step 201: Obtain the database type of the current business and the database type of the next business to be operated on.

[0035] The current business database type refers to the database type of the business that is currently running, while the next business database type refers to the database type of the business that needs to be switched to. Taking a bank management system in the fintech field as an example, the current business database type is Oracle for card issuance, and the next business database type is MySQL for salesperson performance statistics.

[0036] Specifically, the database type of the current service and the database type of the next service can be determined by identifying the server port. For example, the port for Oracle database is 1521, and the port for MySQL database is 3306. Alternatively, different database types can be identified using specific statements. For instance, the specific statements for Oracle database are "select banner from v$version; select banner from v$version where rownum=1; PostgreSQL:selectversion()", and for MySQL database are "select version(); &select@@version; SQL Server:select@@version". In this embodiment, by obtaining the database type of the current service and the database type of the next service, a seamless switch between the current and next services can be achieved, improving service processing speed.

[0037] Step 202: If the database type of the current service is inconsistent with the database type of the next service, send the interface routing instruction for the source database corresponding to the current service. The interface routing instruction includes the target database type and target routing rules corresponding to the next service.

[0038] The interface routing instruction for the source database corresponding to the current service is a command sent by the client to the server for database type routing. This instruction includes the target database type for the next service and the target routing rules. The target database type refers to the database type to be routed to, such as a MySQL database. The target routing rules refer to the routing method used in the database type routing process, such as direct routing rules or primary / secondary switching routing rules.

[0039] Specifically, when the database type of the current business is inconsistent with the database type of the next business, it indicates that a database type switch is required to operate the next business. Therefore, the server receives the interface routing instructions of the source database corresponding to the current business, so as to realize the routing operation of the database interface and thus achieve automatic database switching.

[0040] Step 203: Obtain the pre-annotated adaptive interface routing engine, which includes database interfaces corresponding to multiple different types of databases.

[0041] The adaptive interface routing engine is a pre-annotated interface routing engine used to control and adjust the interface routing when the service calls the DAO layer (data access object, data connection layer). The adaptive interface routing engine includes multiple database interfaces corresponding to different types of databases, that is, one database interface corresponds to one type of database. The adaptive interface routing engine is used to intelligently route to different database interfaces in the future, realize lossless switching of database interfaces, and improve the switching efficiency of database interfaces.

[0042] Specifically, by acquiring a pre-annotated adaptive interface routing engine, database interface routing and switching can be adaptively performed, avoiding the time-consuming, labor-intensive, and risky manual switching. Since different services within the platform require database type switching, the operation is massive and uncertain, involving numerous services across multiple components. To ensure a safe and lossless migration without affecting current services and improving operational efficiency, this embodiment utilizes a pre-annotated adaptive interface routing engine to achieve automatic switching between different database types, thereby enhancing the security and compatibility of platform business operations.

[0043] In one specific implementation, the adaptive interface routing engine can expand the database types that need to be migrated by adding new database types. When a user needs to be routed to a database interface of a new database type, it can be automatically added and the corresponding operations can be performed. For example, if the currently used Oracle DAO layer needs to be migrated to a MySQL DAO layer, only the corresponding MySQL DAO layer needs to be added, ensuring that the SQLIDs of the Oracle DAO layer and the MySQL DAO layer are consistent. The adaptive interface routing engine achieves efficient migration of data between different database types without requiring developers to redevelop the database or manually synchronize data, thus improving the efficiency and intelligence of database interface switching.

[0044] Step 204: Find the database interface that matches the target database type from the adaptive interface routing engine as the target interface.

[0045] The target interface is the database interface in the adaptive interface routing engine, and the database type corresponding to the database interface matches the target database type. In this embodiment, the matching means that the target database type is consistent with the database type corresponding to the database interface.

[0046] Specifically, based on the target database type, the adaptive interface routing engine queries for database types that match the target database type as the successfully matched database types, and the database interface corresponding to the successfully matched database type is the target interface.

[0047] Step 205: Route the source database to the target interface according to the target routing rules to operate the next business.

[0048] Specifically, based on the target routing rules, the source database is routed to the target interface, and then the next business operation is performed. This achieves the switching of the source database to the database corresponding to the target database type, thereby realizing lossless database switching and intelligent routing of database interfaces. This embodiment performs intelligent database routing through a pre-annotated adaptive interface routing engine, ensuring safe and lossless migration of data of different database types without being aware of the current business, improving the compatibility of business on the same platform and the efficiency and security of business operations within the platform.

[0049] The aforementioned database interface routing method obtains the database type of the current business and the database type of the next business to be operated on. If the database type of the current business and the database type of the next business are inconsistent, an interface routing instruction for the source database corresponding to the current business is sent. This instruction includes the target database type and target routing rules for the next business. A pre-annotated adaptive interface routing engine is obtained, which includes multiple database interfaces corresponding to different database types. The adaptive interface routing engine finds a database interface matching the target database type as the target interface. The source database is routed to the target interface according to the target routing rules to operate the next business. This achieves lossless database switching and intelligent database interface routing. Using the embodiments of this application, secure and lossless data migration between different database types is guaranteed, without affecting the current business, improving the compatibility of businesses on the same platform and the efficiency and security of business operations within the platform.

[0050] In one embodiment, a pre-annotated adaptive interface routing engine is obtained. The adaptive interface routing engine includes database interfaces corresponding to multiple different types of databases, including: configuring the first data source corresponding to each of the multiple database types in the Spring configuration file; automatically annotating each first data source to generate annotation code; adding multiple preset routing rules to the annotation code to generate routing code, wherein the preset routing rules include target routing rules; binding the routing code to the preset DAO layer in a point-in manner to generate the corresponding database interface for each first data source; and forming an adaptive interface routing engine based on the corresponding database interface of the first data source.

[0051] Here, the primary data source refers to the database used by the business within the same platform, and one primary data source corresponds to one database type. Preset routing rules refer to the pre-defined methods used to determine database interface routes. These rules are configured according to different scenarios and can include whitelist routing rules, proportional switching routing rules, primary / secondary switching routing rules, dual-write switching routing rules, single-write switching routing rules, etc., to adapt to complex business scenarios and improve the versatility and applicability of routing switching. The pre-defined DAO layer can use JDBC or MyBatis, thus eliminating the need to modify the service layer code.

[0052] Specifically, Spring configuration files, such as `applicationContext.xml`, can be pre-written within the Spring container to store the primary data source. This allows for the configuration of primary data sources for various database types. Then, automatic annotations can be applied to each primary data source. Component scanning can be configured in `applicationContext.xml` to specify which packages and sub-packages' beans should be scanned, identifying classes, fields, and methods configured using annotations. For example, through...<context:component-scan base-package="com.ithema" / > The class, fields, and methods are used to generate annotation code. Then, multiple preset routing rules are added to the annotation code to generate routing code. Finally, the routing code is bound to the preset DAO layer in a point-in approach to generate the corresponding database interface for each first data source. The corresponding database interfaces of the first data sources are combined to obtain the adaptive interface routing engine. Understandably, this embodiment obtains the adaptive interface routing engine through pre-annotation point-in, thereby enabling interface routing to be switched according to corresponding routing rules for different scenarios. This makes the database interface routing in the adaptive interface routing engine controllable and adjustable, improving the wide applicability and intelligence of routing switching.

[0053] In one embodiment, automatic annotation is performed on each data source to generate data source annotation code, including: obtaining the field parameters of each first data source and the corresponding preset annotation code template; loading the field parameters into the preset annotation code template to generate data source annotation code.

[0054] Here, field parameters refer to the characteristic parameters of the fields in each primary data source. Preset annotation code templates refer to pre-configured templates used for annotation code.

[0055] Specifically, the field parameters of each first data source are obtained, and the corresponding preset annotation code template is constructed. The field parameters are loaded into the preset annotation code template to obtain the data source annotation code.

[0056] In one embodiment, the preset routing rules include primary / secondary switching rules, whitelist rules, and write rules; routing the source database to the target interface according to the target routing rules to operate the next business includes: when the target routing rule is a primary / secondary switching rule, routing the source database to the target interface to operate the next business, and returning the business result of operating the next business.

[0057] The primary / secondary switching rule refers to selecting which node's data from the route to return based on the configuration. It allows for flexible selection: the current database's return result can be used as the primary data result, and the new database's return result as the secondary data result; alternatively, the new database's return result can be used as the primary data result, and the current database's return result as the primary data result. The whitelist rule refers to routing requests only to specific resources, while maintaining access to the original DAO layer in other cases. The write rule refers to the rules for data writing, including single-sided and double-sided writes. For example, if the source database is an Oracle database and the migration target database is a MySQL database, it can be configured to write only to the MySQL database, only to the Oracle database, or both databases (double-sided write). It's worth noting that double-sided writes facilitate data comparison and, in the event of migration failure, will not affect the operation of the original database.

[0058] Specifically, when the target routing rule is a primary / secondary switching rule, the source database is routed to the target interface to operate the next business, and the business result of operating the next business is returned, thus realizing the routing switching in the primary / secondary switching scenario.

[0059] In one embodiment, routing the source database to the target interface according to the target routing rule to operate the next service includes: when the target routing rule is a whitelist rule, selecting a preset number of database interfaces from the adaptive interface routing engine to determine the whitelist list; routing the source database to the database interface in the whitelist list to operate the next service, and returning a first result of operating the next service; routing the source database to the target interface to operate the next service, and returning a second result of operating the next service; and determining the service result of the next service based on the first result and the second result.

[0060] Specifically, when the target routing rule is a whitelist rule, a preset number of database interfaces are selected from the adaptive interface routing engine to form a whitelist list. The source database is routed to the database interfaces in the whitelist list to operate the next business and the first result of operating the next business is returned. Then, the source database is routed to the target interface to operate the next business and the second result of operating the next business is returned. The first result or the second result can be determined as the business result of the next business. Preferably, the first result is determined as the business result of the next business. Through the whitelist rule, the scope of impact of the early switching risk is effectively controlled.

[0061] In one embodiment, the write rules include one-sided write rules and two-sided write rules; routing the source database to the target interface according to the target routing rule to operate the next service includes: when the target routing rule is a one-sided write rule, routing the source database to the target interface to operate the next service and returning a third result of operating the next service; writing the third result to the source database or the target database to generate the service result of the next service; when the target routing rule is a two-sided write rule, obtaining the source database and routing it to the target interface to operate the next service, and returning a fourth result of operating the next service; writing the fourth result to the source database and the target database respectively to generate a fifth result and a sixth result; and determining the service result of the next service based on the fifth result and the sixth result.

[0062] Specifically, when the target routing rule is a one-sided write rule, the source database is routed to the target interface to operate the next business, and a third result of operating the next business is returned. The third result is then written to the source database or the target database to generate the business result of the next business.

[0063] When the target routing rule is a two-sided write rule, the system retrieves the route from the source database to the target interface to operate the next service, and returns the fourth result of operating the next service. This fourth result is then written to both the source and target databases, generating the fifth and sixth results. By comparing these results, the service outcome for the next service can be determined. This two-sided write approach enables intelligent comparison, switching, and routing, effectively achieving a smooth transition and reducing risk.

[0064] In one embodiment, the adaptive interface routing engine further includes multiple business modules, and the method further includes: finding a business module consistent with the next business from the adaptive interface routing engine as the target module; and using the adaptive interface routing engine to route the current business to the target module.

[0065] Here, a business module refers to a business function module within the same platform, used for routing and switching between interfaces of business modules. Multiple business modules and their corresponding business module interfaces can be added to the adaptive interface routing engine.

[0066] Specifically, the adaptive interface routing engine finds the business module that matches the next business as the target module, and then uses the adaptive interface routing engine to route the current business to the target module, thus realizing intelligent switching of business.

[0067] like Figure 3 As shown, in one embodiment, a database interface routing device is proposed, comprising:

[0068] The first acquisition module 301 is used to acquire the database type of the current business and the database type of the next business to be operated on.

[0069] The sending module 302 is used to send an interface routing instruction for the source database corresponding to the current service when the database type of the current service is inconsistent with the database type of the next service. The interface routing instruction includes the target database type and target routing rule corresponding to the next service.

[0070] The second acquisition module 303 is used to acquire the pre-annotated adaptive interface routing engine, which includes database interfaces corresponding to multiple different types of databases.

[0071] The lookup module 304 is used to find a database interface that matches the target database type from the adaptive interface routing engine as the target interface;

[0072] The routing module 305 is used to route the source database to the target interface according to the target routing rules in order to operate the next service.

[0073] In one embodiment, the second acquisition module 303 includes:

[0074] Configuration unit, used to configure the primary data source for various database types in the Spring configuration file;

[0075] Annotation unit, used to automatically annotate each of the first data sources and generate annotation code;

[0076] An adding unit is used to add multiple preset routing rules to the annotation code and generate routing code, wherein the preset routing rules include the target routing rule;

[0077] The binding unit is used to bind the routing code to the preset DAO layer in a cutting-in manner, and generate the corresponding database interface for each first data source;

[0078] The generation unit is used to form the adaptive interface routing engine based on the corresponding database interface of the first data source.

[0079] In one embodiment, the annotation unit includes:

[0080] The sub-unit is used to obtain the field parameters of each of the first data sources and the corresponding preset annotation code templates;

[0081] The loading sub-unit is used to load the field parameters into the preset annotation code template and generate the data source annotation code.

[0082] In one embodiment, the preset routing rules include primary / secondary switching rules, whitelist rules, and write rules; the routing module 305 includes:

[0083] The first routing unit is configured to route the source database to the target interface when the target routing rule is the primary / secondary switching rule, so as to operate the next service and return the service result of operating the next service.

[0084] In one embodiment, the routing module 305 includes:

[0085] The selection unit is used to select a preset number of database interfaces from the adaptive interface routing engine to form a whitelist when the target routing rule is the whitelist rule.

[0086] The second routing unit is used to route the source database to the database interface in the whitelist to operate the next service, and return the first result of operating the next service;

[0087] The third routing unit is used to route the source database to the target interface to operate the next service, and return the second result of operating the next service;

[0088] The first determining unit is used to determine the business result of the next business based on the first result and the second result.

[0089] In one embodiment, the write rules include single-sided write rules and double-sided write rules; the routing module 305 includes:

[0090] The fourth routing unit is used to route the source database to the target interface when the target routing rule is the one-sided write rule, so as to operate the next service and return the third result of operating the next service;

[0091] The first writing unit is used to write the third result into the source database or the target database to generate the business result of the next business.

[0092] The fifth routing unit is used to obtain the source database route to the target interface when the target routing rule is the double-sided write rule, so as to operate the next service and return the fourth result of operating the next service;

[0093] The second writing unit is used to write the fourth result into the source database and the target database respectively, and generate the fifth result and the sixth result;

[0094] The second determining unit is used to determine the business result of the next business based on the fifth result and the sixth result.

[0095] In one embodiment, the database interface routing device further includes:

[0096] The first search module is used to search the adaptive interface routing engine for a business module that is consistent with the next business as the target module.

[0097] The first routing module is used to route the current service to the target module using the engine adaptive interface routing engine.

[0098] As can be seen from the above technical solution, this application obtains the database type of the current business and the database type of the next business to be operated. When the database type of the current business and the database type of the next business are inconsistent, it sends an interface routing instruction for the source database corresponding to the current business. The interface routing instruction includes the target database type and target routing rules corresponding to the next business. It obtains a pre-annotated adaptive interface routing engine, which includes multiple database interfaces corresponding to different types of databases. It finds a database interface that matches the target database type from the adaptive interface routing engine as the target interface. According to the target routing rules, the source database is routed to the target interface to operate the next business. This achieves lossless switching of databases and intelligent routing of database interfaces. By adopting the embodiments of this application, it ensures the safe and lossless migration of data of different database types without the awareness of the current business, and improves the compatibility of businesses on the same platform and the efficiency and security of business operations on the platform.

[0099] Figure 4 An internal structural diagram of a computer device in one embodiment is shown. This computer device may specifically be a server, including but not limited to high-performance computers and high-performance computer clusters. Figure 4 As shown, the computer device includes a processor, memory, and network interface connected via a system bus. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and may also store a computer program. When executed by the processor, this computer program enables the processor to implement a database interface routing method. The internal memory may also store a computer program, which, when executed by the processor, enables the processor to implement the database interface routing method. Those skilled in the art will understand that... Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0100] In one embodiment, the database interface routing method provided in this application can be implemented as a computer program, which can be implemented in, for example... Figure 4 The computer device shown runs on this device. The computer device's memory can store the various program templates that make up the interface routing device of the database. For example, a first acquisition module 301, a sending module 302, a second acquisition module 303, a search module 304, and a routing module 305.

[0101] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the following database interface routing method:

[0102] Get the database type of the current business and get the database type of the next business to be operated on;

[0103] If the database type of the current service is inconsistent with the database type of the next service, an interface routing instruction for the source database corresponding to the current service is sent. The interface routing instruction includes the target database type and target routing rule corresponding to the next service.

[0104] Obtain a pre-annotated adaptive interface routing engine, which includes database interfaces corresponding to multiple different types of databases;

[0105] The adaptive interface routing engine searches for a database interface that matches the target database type as the target interface;

[0106] The source database is routed to the target interface according to the target routing rules in order to operate the next service.

[0107] A computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the following database interface routing method:

[0108] Get the database type of the current business and get the database type of the next business to be operated on;

[0109] If the database type of the current service is inconsistent with the database type of the next service, an interface routing instruction for the source database corresponding to the current service is sent. The interface routing instruction includes the target database type and target routing rule corresponding to the next service.

[0110] Obtain a pre-annotated adaptive interface routing engine, which includes database interfaces corresponding to multiple different types of databases;

[0111] The adaptive interface routing engine searches for a database interface that matches the target database type as the target interface;

[0112] The source database is routed to the target interface according to the target routing rules in order to operate the next service.

[0113] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0114] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0115] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A database interface routing method, characterized in that, The method includes: Get the database type of the current business and get the database type of the next business to be operated on; If the database type of the current service is inconsistent with the database type of the next service, an interface routing instruction for the source database corresponding to the current service is sent. The interface routing instruction includes the target database type and target routing rule corresponding to the next service. An adaptive interface routing engine with pre-annotated entry is obtained based on preset routing rules. The adaptive interface routing engine includes database interfaces corresponding to multiple different types of databases. The preset routing rules include write rules, and the write rules include at least two-sided write rules. The adaptive interface routing engine searches for a database interface that matches the target database type as the target interface; The source database is routed to the target interface according to the target routing rule to operate the next service, including: when the target routing rule is the two-sided write rule, the source database is obtained and routed to the target interface to operate the next service, and a fourth result of operating the next service is returned; the fourth result is written to the source database and the target database respectively to generate a fifth result and a sixth result; and the service result of the next service is determined based on the fifth result and the sixth result.

2. The database interface routing method as described in claim 1, characterized in that, The process involves obtaining a pre-annotated adaptive interface routing engine, which includes database interfaces corresponding to multiple different types of databases, including: Configure the primary data source for each of the various database types in the Spring configuration file; Automatically annotate each of the first data sources to generate annotation code; Add multiple preset routing rules to the annotation code to generate routing code, wherein the preset routing rules include the target routing rule; The routing code is bound to the preset DAO layer in a cutting-in manner to generate the corresponding database interface for each first data source; The adaptive interface routing engine is formed based on the corresponding database interface of the first data source.

3. The database interface routing method as described in claim 2, characterized in that, The step of automatically annotating each of the first data sources to generate annotation code includes: Obtain the field parameters of each of the first data sources and the corresponding preset annotation code templates; The field parameters are loaded into the preset annotation code template to generate the annotation code.

4. The database interface routing method as described in claim 3, characterized in that, The preset routing rules include primary / secondary switching rules, whitelist rules, and write rules; The step of routing the source database to the target interface according to the target routing rule to operate the next service includes: When the target routing rule is the primary / secondary switching rule, the source database is routed to the target interface to operate the next service and the service result of operating the next service is returned.

5. The database interface routing method as described in claim 4, characterized in that, The step of routing the source database to the target interface according to the target routing rule to operate the next service includes: When the target routing rule is the whitelist rule, a preset number of the database interfaces are selected from the adaptive interface routing engine to form the whitelist list; The source database is routed to the database interface in the whitelist to operate the next service, and the first result of operating the next service is returned; The source database is routed to the target interface to operate the next service, and a second result of operating the next service is returned; The business outcome of the next business is determined based on the first and second results.

6. The database interface routing method as described in claim 3, characterized in that, The write rules also include one-sided write rules; When the target routing rule is the one-sided write rule, the source database is routed to the target interface to operate the next service, and the third result of operating the next service is returned; The third result is written into the source database or the target database to generate the business result of the next business.

7. The database interface routing method as described in claim 1, characterized in that, The adaptive interface routing engine also includes multiple business modules, and the method further includes: The adaptive interface routing engine searches for a business module that matches the next business as the target module. The adaptive interface routing engine is used to route the current service to the target module.

8. A database interface routing device, characterized in that, The device includes: The first acquisition module is used to acquire the database type of the current business and the database type of the next business to be operated on. The sending module is used to send an interface routing instruction for the source database corresponding to the current service when the database type of the current service is inconsistent with the database type of the next service. The interface routing instruction includes the target database type and target routing rules corresponding to the next service. The second acquisition module is used to acquire the pre-annotated adaptive interface routing engine based on preset routing rules. The adaptive interface routing engine includes database interfaces corresponding to multiple different types of databases. The preset routing rules include writing rules, and the writing rules include at least two-sided writing rules. The lookup module is used to find a database interface that matches the target database type from the adaptive interface routing engine as the target interface; A routing module is used to route the source database to the target interface according to the target routing rule to operate the next service. This includes: when the target routing rule is the two-sided write rule, obtaining the source database and routing it to the target interface to operate the next service, and returning a fourth result of operating the next service; writing the fourth result to the source database and the target database respectively to generate a fifth result and a sixth result; and determining the service result of the next service based on the fifth result and the sixth result.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the interface routing method for the database as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the interface routing method for the database as described in any one of claims 1 to 7.