Application program switching method and device for heterogeneous database, equipment and medium

By using automated code conversion and testing methods, the source database compilation text is converted into target database-compatible compilation text, and functional testing is performed under the program design architecture. This solves the accuracy and cost issues in heterogeneous database switching and realizes an efficient and low-cost database switching solution.

CN121597272APending Publication Date: 2026-03-03INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511835709.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-08
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing technologies lack sufficient reliability and accuracy in automatically converting query statements when switching between heterogeneous databases. This results in high costs for manual verification, low reusability of the switching process, and significant challenges and risks associated with reconstruction.

Method used

By obtaining the static code of the application from the source database, and based on the code compilation rules of the target database type mapping, the compiled text of the source database is converted into the compiled text to be tested, and then packaged into the program to be tested under the preset program design architecture. Functional testing is performed, and after verification, the program to be tested is used as a component program of the target application.

Benefits of technology

It achieves efficient, low-cost, and highly accurate heterogeneous database switching, reduces waste of human resources, avoids program errors and losses, and ensures application availability and switching reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597272A_ABST
    Figure CN121597272A_ABST
Patent Text Reader

Abstract

The invention provides an application program switching method for a heterogeneous database, relates to the field of computer software development, and can be applied to the field of financial science and technology. The method comprises the following steps: in response to a received heterogeneous database switching request, obtaining an application program static code, and performing data extraction on the application program static code to obtain a source database compiled text; determining a target database type, mapping a code compilation rule according to the target database type, and converting the source database compilation text into a to-be-tested compilation text based on the code compilation rule; based on a preset program design architecture, packaging the to-be-tested compiled text into a to-be-tested program, and performing function test on the to-be-tested program to obtain a test result; and taking the to-be-tested program as a component program of the target application program in response to the test result representing that the to-be-tested program passes the test. The invention further provides an application program switching device and equipment for the heterogeneous database, a storage medium and a program product.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer software development, and more specifically to a method, apparatus, device, medium, and program product for switching applications for heterogeneous databases. Background Technology

[0002] In the software development field, switching between heterogeneous relational databases on the backend has always been a significant challenge for professional developers (such as switching from a T1 type database to a T2 type database). This typically involves tasks such as database driver switching, structured query language syntax conversion, business logic rewriting, performance tuning, coverage testing, and traffic switching solutions. While some existing technologies have implemented query statement conversion for heterogeneous databases, if the converted queries are not validated before being applied to the application, they may cause risks such as program crashes. Therefore, substantial manual steps are still required for query statement validation, business process validation, and other steps. This manual verification is still necessary for managing development risks and product quality.

[0003] However, existing applications or systems are products developed through historical version iterations, often carrying heavy technical debt and making reconstruction difficult. Therefore, the drawbacks of existing technologies for switching backend heterogeneous data are: 1) The reliability of automatic query statement conversion is questionable. Even automatic conversion accuracy cannot reach 100%, and database operations are generally highly sensitive, especially for customer data involving accounting; errors can lead to significant losses. 2) High R&D and verification costs. Faced with massive amounts of existing applications, even if existing technologies can automatically convert query statements, significant manual and time costs are still required for business testing and verification. 3) Low reusability of the switching work. Due to the diverse types of heterogeneous databases, when the source and target database types change, the switching work needs to be redone, resulting in low reusability of existing switching work and wasted human resources. Summary of the Invention

[0004] In view of the above problems, this application provides a highly reliable method, apparatus, device, medium and program product for switching applications for heterogeneous databases.

[0005] According to a first aspect of this application, a method for switching applications to heterogeneous databases is provided, comprising: in response to receiving a heterogeneous database switching request, obtaining the application static code of the source database involved in the switching request, extracting data from the application static code to obtain the source database compiled text; confirming the target database type of the target database involved in the switching request, mapping code compilation rules according to the target database type, and converting the source database compiled text into a test compiled text adapted to the target database type based on the code compilation rules; based on a preset program design architecture, encapsulating the test compiled text into a test program, and performing functional testing on the test program to obtain test results; in response to the test results indicating that the test program has passed the test, using the test compiled text as the target database compiled text corresponding to the target database, and using the test program as a component program of the target application.

[0006] According to an embodiment of this application, based on a preset program design architecture, the compiled text to be tested is encapsulated into a program to be tested, including: under the constraints of the program design architecture, the compiled text to be tested is encapsulated based on meta-table information to generate an architecture component program file; wherein, the meta-table information includes field names, field types, index names and index types extracted from the compiled text to be tested; the program startup configuration is mapped according to the program design architecture, and the architecture component program file is configured as an executable program to be tested based on the program startup configuration.

[0007] According to an embodiment of this application, performing functional testing on the program under test and obtaining test results includes: obtaining the functional categories of the program under test; wherein, the functional categories include at least one of query, add, delete, update, and merge; mapping functional test prompts to a preset functional test prompt word library based on the functional categories; the preset functional test prompt word library includes a correspondence between multiple functional categories and functional test prompts, each functional test prompt word being used to indicate the functional testing process of the corresponding functional category; and, based on the change prompts of the functional test prompts, making data changes in the target database corresponding to the change prompts to obtain the changed target database. Data; Based on the execution prompts of the functional test prompts, the corresponding call entry point of the program under test is invoked to execute the program under test, so as to perform data operations on the modified data of the target database in accordance with the functional category, and obtain the executed data of the target database; wherein, the call entry point is configured to: receive the call signal and trigger the parameter loading and program execution of the program under test according to the call signal; based on the verification prompts of the functional test prompts, the modified data and executed data of the target database are used to perform verification corresponding to the verification prompts, and the verification result is used as the test result, wherein the verification result that matches the verification prompt indicates that the program under test passes the test.

[0008] According to an embodiment of this application, converting source database compiled text into test compiled text adapted to the target database type based on code compilation rules includes: extracting source table names and source metatable information from the source data in the source database compiled text; matching the source table names in a preset data table mapping set to obtain the corresponding target table names in the target database, wherein the preset data table mapping set stores the association relationships between table names, source metatable information, target database table names, and target metatable information of multiple source databases, and stores the information mapping relationship between source metatable information and target metatable information; mapping the corresponding target metatable information in the preset data table mapping set based on the source metatable information; and converting the source database compiled text into test compiled text adapted to the target database type based on code compilation rules, wherein, during the conversion, the source table names in the source table data compiled text are replaced with the target table names, and the source metatable information is replaced with the corresponding target metatable information.

[0009] According to an embodiment of this application, using the program under test as a component program of the target application includes: identifying the source program and source call entry point corresponding to the source database compilation text in the static code of the application; replacing the source program corresponding to the source call entry point in the static code of the application with the program under test; and replacing the source driver program used to connect the source program and the source database in the application component program with the target driver program used to connect the program under test and the target database, thereby obtaining the target application.

[0010] According to an embodiment of this application, using the program under test as a component program of the target application includes: identifying the source call entry point of the source program corresponding to the compiled text of the source database in the static code of the application; replacing the code in the static code of the application that calls the source call entry point with the code that calls the call entry point of the program under test; and replacing the source driver program in the application component program that connects the source program and the source database with the target driver program that connects the program under test and the target database, thereby obtaining the target application.

[0011] According to an embodiment of this application, the method further includes: in response to a received application rollback request for a heterogeneous database, replacing the code in the static code of the target application that is used to call the program under test with the code that is used to call the source program, and replacing the target driver in the target application component program that is used to connect the program under test and the target database with the source driver that is used to connect the source program and the source database, thereby obtaining the application.

[0012] The second aspect of this application provides an application switching device for heterogeneous databases, comprising: an identification module, configured to, in response to receiving a heterogeneous database switching request, acquire the application static code of the source database involved in the switching request, extract data from the application static code, and obtain the source database compiled text; a conversion module, configured to, confirm the target database type of the target database involved in the switching request, map code compilation rules according to the target database type, and convert the source database compiled text into a test compiled text adapted to the target database type based on the compilation rules; a testing module 730, configured to, based on a preset program design architecture, encapsulate the test compiled text into a test program, perform functional testing on the test program, and obtain test results; and a target application determination module, configured to, in response to the test results indicating that the test program has passed the test, use the test compiled text as the target database compiled text corresponding to the target database, and use the test program as a component program of the target application.

[0013] A third aspect of this application provides an electronic device comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.

[0014] A fourth aspect of this application also provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implement the steps of the above-described method.

[0015] The fifth aspect of this application also provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method.

[0016] According to embodiments of this application, by analyzing the code of existing applications, the source database compilation text used for interaction with the source database in the application code is automatically identified. Based on the compilation rules of the target database, the source database compilation text is converted into test compilation text. Through the application's program design architecture, the test compilation text is encapsulated into a test program and tested. When the test passes, the test program is used as a component of the target application. Therefore, when switching a large number of existing applications to heterogeneous backend databases, the conversion of database compilation text in the applications, as well as program adjustments and testing, can be automatically implemented, ensuring the availability of the applications after the backend database switch, avoiding program runtime errors and losses caused by database switching, and reducing labor costs. This provides an efficient, low-cost, highly accurate, and low-risk application switching solution for heterogeneous databases, effectively solving the problem of switching existing applications to heterogeneous relational databases. Attached Figure Description

[0017] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0018] Figure 1 The illustration schematically depicts an application scenario diagram of an application switching method, apparatus, device, medium, and program product for heterogeneous databases according to embodiments of this application;

[0019] Figure 2 A flowchart illustrating an application switching method for heterogeneous databases according to an embodiment of this application is shown schematically.

[0020] Figure 3 This illustration schematically shows a data flow diagram of a program design architecture for static code of an application according to an embodiment of this application;

[0021] Figure 4 The illustration shows a schematic diagram of preset prompt words according to an embodiment of this application;

[0022] Figure 5 This illustration schematically shows a multi-agent collaboration diagram of an application switching method for heterogeneous databases based on multi-agent collaboration according to an embodiment of this application.

[0023] Figure 6 This illustration shows a schematic diagram of the data flow of an application switching method for heterogeneous databases based on multi-agent collaboration according to an embodiment of this application;

[0024] Figure 7 This schematically illustrates a structural block diagram of an application switching device for heterogeneous databases according to an embodiment of this application; and

[0025] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing an application switching method for heterogeneous databases according to an embodiment of this application. Detailed Implementation

[0026] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.

[0027] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0028] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0029] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).

[0030] In the technical solution of this application, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, and displayed data) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with relevant laws, regulations, and standards, and necessary processing measures have been taken. They do not violate public order and good morals, and corresponding operation entry points are provided for users to choose to authorize or refuse.

[0031] In scenarios involving automated decision-making using personal information, the methods, devices, and systems provided in this application all offer users corresponding entry points for choosing to agree to or reject the automated decision-making results; if the user chooses to reject, the process proceeds to the expert decision-making stage. Here, "automated decision-making" refers to the activity of automatically analyzing and assessing the risks of methods through computer programs and making decisions. Here, "expert decision-making" refers to the activity of making decisions by personnel who specialize in a particular field, possess specialized experience, knowledge, and skills, and have reached a certain level of professional expertise.

[0032] Figure 1 The illustration shows an application scenario diagram for application switching of heterogeneous databases according to an embodiment of this application.

[0033] like Figure 1As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0034] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0035] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0036] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0037] It should be noted that the application switching method for heterogeneous databases provided in this application embodiment can generally be executed by server 105. Correspondingly, the application switching device for heterogeneous databases provided in this application embodiment can generally be located in server 105. The application switching method for heterogeneous databases provided in this application embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the application switching device for heterogeneous databases provided in this application embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.

[0038] It should be understood that Figure 1The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0039] The following will be based on Figure 1 The described scene, through Figures 2-6 The application switching method for heterogeneous databases according to embodiments of this application will be described in detail.

[0040] Figure 2 A flowchart illustrating an application switching method for heterogeneous databases according to an embodiment of this application is shown schematically.

[0041] like Figure 2 As shown, the application switching method for heterogeneous databases in this embodiment includes operations S210 to S240.

[0042] In operation S210, in response to receiving a heterogeneous database switching request, the application static code of the source database involved in the switching request is obtained, data is extracted from the application static code, and the compiled text of the source database is obtained.

[0043] For example, in the field of software development, an application (abbreviated as App) is a collection of one or more computer programs designed to perform specific tasks to directly meet the needs of end users. Applications typically have a graphical user interface, allowing users to interact with the program through clicking, dragging, and typing. Some applications also interact with other programs through a command-line interface. Applications cannot exist independently; they must run on a specific operating system or in a browser environment. Depending on the platform, applications include desktop applications, web applications, mobile applications, etc.

[0044] For example, the operation of applications such as desktop applications, web applications, and mobile applications depends on the execution of their code. During the application development phase, code is written based on a programming architecture. After development is completed, the code is compiled and run, and then deployed to a server to form an application that can be used by users. The static code of the application refers to this runnable code written based on the programming architecture.

[0045] For example, in the field of software development, program design architecture, often referred to as software architecture, is the high-level structural design of a software system. It defines the various components of the system, the relationships between them, and the principles and guidelines that constrain their design. A complete architecture description typically includes: (1) Structure, defining which components, modules, services, or layers constitute the system; (2) Connections, defining how these components interact and communicate, such as API (Application Programming Interface) calls, message queues, and event-driven architecture; and (3) Decisions and constraints, defining which technologies and frameworks are selected and which specifications and standards must be followed. For example, layered architecture divides the system horizontally into multiple layers, each with clearly defined responsibilities, and is suitable for traditional enterprise applications and web applications.

[0046] For example, a layered architecture divides an application vertically into several layers, each of which is a cohesive software module with clearly defined responsibilities. The most classic and basic is the three-tier architecture, as shown in Table 1.

[0047] Table 1. Structure and Function of the Three-Layer Structure

[0048]

[0049] As shown in Table 1, the layered architecture follows the principle of unidirectional dependency, with each layer providing services to its upper layer through a clear interface. The upper layer (such as the presentation layer) depends on the interface of the lower layer (such as the business logic layer), and the dependency relationship can only be from top to bottom, that is, the presentation layer depends on the business logic layer, and the business logic layer depends on the data access layer.

[0050] Figure 3 This illustration shows a schematic diagram of the data flow in a program design architecture of static code for an application according to an embodiment of this application.

[0051] For example, such as Figure 3As shown, when a user clicks "Search" on the application's interface, the application receives the URL (Uniform Resource Locator) pointing to the query request and routes it to the corresponding Controller in the presentation layer of the application. The Controller receives the query link request, assembles the parameters, and calls the Service in the business logic layer. The Service receives the parameters, applies the business rules, and then calls the Dao in the data access layer. The Dao layer constructs a query statement for the database (i.e., the compiled text of the source data) based on the received parameters, executes the corresponding CRUD operations in the database, and returns the execution results. In sequence, the raw data is converted into data objects by the data access layer, the business logic layer performs business processing on the data, and the presentation layer assembles the processed objects into a format suitable for UI display. Finally, the data objects are rendered as HTML and displayed to the user in the UI.

[0052] For example, the code for constructing a query statement in Dao is shown in Table 2.

[0053] Table 2. Query statement code portion in the data access layer

[0054]

[0055] According to embodiments of this application, the source database compiled text generally refers to the query statement for the database. The functions of the query statement include adding, modifying, updating, deleting, merging, etc. For relational databases, the source database compiled text is generally written based on the rules of Structured Query Language. For example, the source data compiled text in Table 2 is: "SELECT id,user_name,desc From orders Where id=ID".

[0056] For example, program design architecture also includes development frameworks commonly used in program design.

[0057] In operation S220, the target database type of the target database involved in the switching request is confirmed, the code compilation rules are mapped according to the target database type, and the source database compilation text is converted into test compilation text adapted to the target database type based on the code compilation rules.

[0058] For example, the code compilation rules include at least one of the following: compilation syntax, function syntax, field types, and pagination mechanism corresponding to the target database type.

[0059] For example, if the source database is of type T1, and the source compiled text in the application is "SELECT id,user_name FROM database1.users ORDER BY create_time DESC LIMIT 10, 5", then when converted to a target database of type T2, the resulting compiled text will be "SELECT id,user_name FROM database1.users ORDER BY create_time DESC LIMIT 5 OFFSET 10". Here, the source database refers to database1, the target database refers to database1 in T2, users is a table in the source / target database, id and user_name are fields in the table, and SELECT, FROM, ORDER BY, DESC, and LIMIT are syntax keywords in the code compilation rules for type T1 databases; SELECT, FROM, ORDER BY, DESC, LIMIT, and OFFSET are syntax keywords in the code compilation rules for type T2 databases.

[0060] For example, the code compilation rules are the language rules for query statements specified in the official database documentation. These compilation rules include: data types in the database (character types, numeric types, boolean types, etc.), query statement syntax, etc. In operation S230, based on the preset program design architecture, the compiled text to be tested is encapsulated into a program to be tested, and functional tests are performed on the program to be tested based on preset test prompts to obtain test results.

[0061] For example, the preset program design architecture is a multi-layer architecture, which encapsulates the query statement into a program call chain of Controller, Service, dao, mapper, and query statement. This call chain encapsulates the program under test, which is the compiled text to be tested.

[0062] For example, Figure 4 A schematic diagram illustrating preset prompts according to an embodiment of this application is shown.

[0063] like Figure 4As shown, the preset prompt word library includes functional test prompt words corresponding to functional categories. The functional testing steps mainly include: data preparation, program execution, and data validation stages. The preset prompt words include the test steps. For different DML (Data Manipulation Language) categories of query statements, the test process is slightly different. When performing functional testing on the program under test based on the preset test prompt words, first, according to the operation category of the compiled text under test: Delete, Insert, Update, Select, Merge. When the operation category is Delete, the preset prompt words include first inserting the case data, then calling and executing the program under test to execute the query statement's delete operation on the database (e.g., DB Delete), and then verifying in the validation stage whether the executed DB Delete has deleted the case data inserted in the preparation stage. When the operation category is Insert, the preset prompt words include first deleting the case data, then calling and executing the program under test to execute the query statement's insert operation (e.g., DBInsert), and then verifying in the validation stage whether the executed DB Insert has re-inserted the case data deleted in the preparation stage. When the operation type is update, the preset prompts include: first, delete a case data record; then, insert a case data record with different content from the deleted data; then, execute the program under test to perform an update operation of the query statement (e.g., DB Update); and then, in the verification phase, verify whether the executed DB Update restores the data from the preparation phase to the state before the case data was deleted. When the operation type is selection, the preset prompts include: first, delete a case data record; then, insert a case data record with the same content as the deleted data; then, execute the program under test to perform a query operation of the query statement (e.g., Gauss Select); and then, in the verification phase, verify whether the result of the executed DB Select is the same as before the data preparation. When the operation type is merge, the preset prompts include prompts for both the Insert and Update phases.

[0064] For example, after the data verification phase verifies the execution of the program under test, the target database is restored to the state before the data preparation phase. That is, the execution of the program under test offsets the changes made to the target database during the data preparation phase, which is considered a successful test.

[0065] For example, based on the target database type and the application's program framework, a driver for the target database type is automatically configured for the program to be executed. For instance, in a program written in Java, a JDBC driver is used to connect to a database of type T1.

[0066] In operation S240, in response to the test result indicating that the program under test has passed the test, the compiled text under test is used as the target database compiled text corresponding to the target database, and the program under test is used as the target application.

[0067] For example, if the test passes, the compiled text under test is used as the target database compiled text corresponding to the target database, and the program under test is used as the target application. If the test fails, the compiled text under test is regenerated, packaged, and tested through a feedback mechanism until the test passes.

[0068] Figure 5 The illustration shows a schematic diagram of a multi-agent collaboration method for switching applications on heterogeneous databases based on multi-agent collaboration according to an embodiment of this application.

[0069] According to embodiments of this application, such as Figure 5As shown, the application switching method for heterogeneous databases is completed collaboratively by multiple agents. An AI agent (Artificial Intelligence Agent) is a computational entity with autonomous perception, reasoning, decision-making, and action capabilities, capable of achieving preset goals or dynamically adapting to environmental changes through intelligent algorithms in a specific environment. MCP (Model Context Protocol) is an open-source standard designed to allow large models to connect to and invoke various external tools in a standardized manner, much like using a USB-C (Universal Serial Bus C-Type) interface. The central control agent connects with various sub-agents (identification agent, transformation agent, testing agent, and target application output agent). The central control agent drives and controls several other sub-agents through the MCP protocol to perform query syntax transformation and self-testing. Each sub-agent can choose different backend large models or uniformly use the same large model (such as various open-source and commercial large models). The process involves several steps: First, a recognition agent responds to a received heterogeneous database switching request by acquiring the application static code of the source database involved in the switching request. Data extraction is performed on the application static code to obtain the source database compiled text. Second, a conversion agent confirms the target database type involved in the switching request, maps code compilation rules according to the target database type, and converts the source database compiled text into a test compiled text adapted to the target database type. Third, a testing agent, based on a preset program design architecture, encapsulates the test compiled text into a test program and performs functional testing on the test program based on preset test prompts, obtaining the test results. Finally, a target application output agent responds to the test results, indicating that the test program has passed the test. The test compiled text is then used as the target database compiled text corresponding to the target database, and the test program is used as a component program of the target application.

[0070] According to embodiments of this application, by analyzing the code of existing applications, the source database compilation text used for interaction with the source database in the application code is automatically identified. Based on the compilation rules of the target database, the source database compilation text is converted into test compilation text. Through the application's program design architecture, the test compilation text is encapsulated into a test program and tested. When the test passes, the test program is used as a component program of the target application. Therefore, when switching a large number of existing applications to heterogeneous backend databases, the conversion of database compilation text in the applications, as well as program adjustments and testing, can be automatically implemented, ensuring the availability of the applications after the backend database switch, avoiding program runtime errors and losses caused by database switching, and reducing labor costs. This provides an efficient, low-cost, highly accurate, and low-risk application switching solution for heterogeneous databases, effectively solving the problem of switching existing applications to heterogeneous relational databases.

[0071] According to an embodiment of this application, based on a preset program design architecture, the compiled text to be tested is encapsulated into a program to be tested, including: under the constraints of the program design architecture, the compiled text to be tested is encapsulated based on meta-table information to generate an architecture component program file; wherein, the meta-table information includes field names, field types, index names and index types extracted from the compiled text to be tested; the program startup configuration is mapped according to the program design architecture, and the architecture component program file is configured as an executable program to be tested based on the program startup configuration.

[0072] Metadata about tables refers to "data that describes the table itself," not the specific business data stored in the table. Simply put, it's a structural description of the table. This includes, but is not limited to, table information such as the table name, column information such as field names and field types, and index information such as index names and index types. This metadata can generally be obtained by querying the database system's data dictionary or information schema.

[0073] For example, in an application designed in Java, the query statement is encapsulated to obtain architectural component programs, including XXController.java, XXService.java, XRDao.java, XXMapper.java, XXMapper.xml, and the program call chain of the query statement. XXMapper.java is a Mapper interface, which includes entity classes corresponding to database tables, Mapper interfaces, and XML files. The XML file contains the query statement. When switching backend databases, different Java code is needed to handle different data types. For example, in database type T1, for Boolean fields, the query statement in the XML file needs to be configured with the type "jdbcType=TINYINT", while for database type T2, it needs to be configured with "jdbcType=BOOLEAN".

[0074] In other program design architectures or development frameworks, data type handling may be done in the Dao.java code by introducing metatable information. When generating architecture component code, different code processing will be automatically performed for the differences between database types.

[0075] According to an embodiment of this application, when switching databases, the processing of data types in the source program for the source database may be different from the processing of data types in the target database. By introducing meta-table information to guide the generation of architecture component code, the program under test can more accurately process the data types of the target database, avoiding the problem of the program under test being unusable due to simply replacing the query statements in the source program without handling the derivative problems after the query statement switching.

[0076] According to an embodiment of this application, performing functional testing on the program under test and obtaining test results includes: obtaining the functional categories of the program under test; wherein, the functional categories include at least one of query, add, delete, update, and merge; mapping functional test prompts to a preset functional test prompt word library based on the functional categories; the preset functional test prompt word library includes a correspondence between multiple functional categories and functional test prompts, each functional test prompt word being used to indicate the functional testing process of the corresponding functional category; and, based on the change prompts of the functional test prompts, making data changes in the target database corresponding to the change prompts to obtain the changed target database. Data; Based on the execution prompts of the functional test prompts, the corresponding call entry point of the program under test is invoked to execute the program under test, so as to perform data operations on the modified data of the target database in accordance with the functional category, and obtain the executed data of the target database; wherein, the call entry point is configured to: receive the call signal and trigger the parameter loading and program execution of the program under test according to the call signal; based on the verification prompts of the functional test prompts, the modified data and executed data of the target database are used to perform verification corresponding to the verification prompts, and the verification result is used as the test result, wherein the verification result that matches the verification prompt indicates that the program under test passes the test.

[0077] For example, based on the change prompts for functional test prompts, corresponding changes are made in the target database, including: parsing the target row of the program under test; when the function category is deletion, the change prompt is addition, and the target row is added to the target database; when the function category is addition, the change prompt is deletion, and the target row is deleted from the target database; when the function category is update, the change prompt is deletion followed by differentiated addition, the target row is first deleted from the target database, and then the row to be updated is added, and the row to be updated is identical to the target row data after being updated by the program under test; when the function category is query, the change prompt is deletion followed by equivalent addition, the target row is first deleted from the target database, and then the target row is added; when the function category is merge, the change prompt is to first perform functional tests for the function category of addition, and then perform functional tests for the function category of update, and in the functional tests of different function categories, changes corresponding to the function category are made in the target database.

[0078] For example, based on the verification prompts of the functional test prompts, verification is performed on the modified data and executed data of the target database to obtain the test results, including: when the functional category is deletion, the verification prompt is "verify deletion," and the difference between the executed data and the modified data is compared. If the difference is that the target row is deleted, the test result is "pass." When the functional category is addition, the verification prompt is "verify addition," and the difference between the executed data and the modified data is compared. If the difference is that the target row is added, the test result is "pass." When the functional category is update, the verification prompt is "verify update," and the difference between the executed data and the modified data is compared. If the difference is that the target row is updated, the test result is "pass." When the functional category is query, the verification prompt is "verify the consistency between the query data and the original case data," and the difference between the executed data and the modified data is compared. If there is no difference, the test result is "pass." When the functional category is merge, the test results for the functional category of addition and the functional category of update are verified separately. If both the addition and update test results are "pass," the test result is "pass."

[0079] According to embodiments of this application, by performing functional tests on the generated program under test, the functional integrity of the program under test is verified, and the accuracy of the application function is ensured. Thus, the program under test that passes the test is used as a component program of the target application, making the target application more accurate.

[0080] According to an embodiment of this application, converting source database compiled text into test compiled text adapted to the target database type based on code compilation rules includes: extracting source table names and source metatable information from the source data in the source database compiled text; matching the source table names in a preset data table mapping set to obtain the corresponding target table names in the target database, wherein the preset data table mapping set stores the association relationships between table names, source metatable information, target database table names, and target metatable information of multiple source databases, and stores the information mapping relationship between source metatable information and target metatable information; mapping the corresponding target metatable information in the preset data table mapping set based on the source metatable information; and converting the source database compiled text into test compiled text adapted to the target database type based on code compilation rules, wherein, during the conversion, the source table names in the source table data compiled text are replaced with the target table names, and the source metatable information is replaced with the corresponding target metatable information.

[0081] For example, since the technical solution of this application focuses on the processing of application switching background database, the premise of this application includes: a target data table of the target database corresponding to the data table in the source database has been established, and the correspondence is stored in a preset data table mapping set. At the same time, the meta table information obtained from the data dictionary of the source database and the meta table information obtained from the data dictionary of the target database are also stored in the preset data table mapping set. For example, this mapping set includes two layers of mapping. The outer mapping is the mapping between table names. After locating the corresponding table name mapping based on the table name, the inner mapping stores the one-to-one mapping between meta table information. For example, the isTrue field of type TINYINT of type T1 corresponds to the isTrue field of type BOOLEAN of type T2.

[0082] According to the embodiments of this application, if only automatic conversion is relied upon without introducing metatable information, then the query statement conversion only involves syntactic conversion, lacks index information, and lacks processing of field data types, which will lead to inaccurate query statement conversion. By introducing metatable information during conversion, the above problems are overcome. The adaptation of indexes, field names, and field types during query statement conversion will be better, and the converted query statement (i.e., the compiled text to be tested) will be more accurate.

[0083] According to an embodiment of this application, using the program under test as a component program of the target application includes: identifying the source program and source call entry point corresponding to the source database compilation text in the static code of the application; replacing the source program corresponding to the source call entry point in the static code of the application with the program under test; and replacing the source driver program used to connect the source program and the source database in the application component program with the target driver program used to connect the program under test and the target database, thereby obtaining the target application.

[0084] For example, Table 3 shows an example of the call entry point, which is / users / {userId} / orders. The corresponding program is the program call chain corresponding to the function getUserOrders in OrderController.java, where userId is the parameter.

[0085] Table 3. Correspondence between call entry points and the program under test

[0086]

[0087] For example, the application corresponding to / users / {userId} / orders can be replaced with the application under test that has passed testing, instead of the application call chain corresponding to the getUserOrders function. With this replacement method, the application package after replacement is identical to the original application.

[0088] According to the embodiments of this application, by directly replacing the code of the call chain of the source program, the application after switching the backend database can be obtained. This can easily and conveniently complete the switching of heterogeneous databases, and the generated application package is about the same size as the original application package, occupying about the same amount of storage resources, thus saving storage space.

[0089] According to an embodiment of this application, using the program under test as a component program of the target application includes: identifying the source call entry point of the source program corresponding to the compiled text of the source database in the static code of the application; replacing the code in the static code of the application that calls the source call entry point with the code that calls the call entry point of the program under test; and replacing the source driver program in the application component program that connects the source program and the source database with the target driver program that connects the program under test and the target database, thereby obtaining the target application.

[0090] For example, the entry point of the source program is: / users / {userId} / orders; the entry point of the program under test is: / new / users / {userId} / orders; the query hyperlinks in the HTML (HyperText Markup Language) file of the display page in the source program are accessed via... <a href="" / users / {userId} / orders”"> This method invokes the source program's entry point, replacing the query hyperlink with... <a href="" / new / users / {userId} / orders”">This allows you to replace the code that calls the source entry point in the static code of an application with the code that calls the entry point of the program under test.

[0091] According to the embodiments of this application, by modifying the call entry point of the source program to the call entry point of the program under test, services can be provided to users in two ways simultaneously. For example, link 1 in page 1 points to the call entry point / orders / AA of the original program; link 2 in page 2 points to / new / users / {userId} / orders in the target application. Thus, the original application and the target application (the components of the two together constitute the target application or system in a broad sense) can provide services together until the call entry points of all component programs or functional modules of the application are updated to the new call entry point, and the switching of the target application is gradually completed.

[0092] According to the embodiments of this application, if the program is directly replaced, the original application and the target application cannot cooperate and there is no transition space. Once an error occurs during operation, the consequences are serious. By replacing the URL, the call entry point can be dynamically and gradually switched until it is completely replaced, ensuring availability during the switching process.

[0093] According to an embodiment of this application, the method further includes: in response to a received application rollback request for a heterogeneous database, replacing the code in the static code of the target application that is used to call the program under test with the code that is used to call the source program, and replacing the target driver in the target application component program that is used to connect the program under test and the target database with the source driver that is used to connect the source program and the source database, thereby obtaining the application.

[0094] For example, the rollback request also includes a rollback request for a specific call entry point. The source call entry point and the call entry point of the program under test are stored in the entry point mapping dataset. Based on the call entry point of the program under test in the rollback request, a call entry point for calling the source program is mapped. The code in the static code of the target application used to call the call entry point of the program under test is replaced with the code used to call the call entry point of the source program. The target driver in the target application component program used to connect the program under test and the target database is replaced with the source driver used to connect the source program and the source database. The driver configuration is modified to the driver configuration of the source database to obtain the application.

[0095] According to the embodiments of this application, if a certain entry point fails, it can be quickly rolled back to ensure the availability of the application. After rolling back, the error can be resolved, and then the application can be relaunched, thus ensuring the high availability of the application in a broad sense.

[0096] Figure 6 The illustration shows a schematic diagram of the data flow of an application switching method for heterogeneous databases based on multi-agent collaboration according to an embodiment of this application.

[0097] According to an embodiment of this application, the data processing flow diagram in a complete technical solution is as follows: Figure 6 As shown, the connection between the central control agent and the various sub-agents is not shown. The central control agent drives and controls several other sub-agents through the MCP protocol to perform query statement syntax conversion and self-testing. Each sub-agent can choose different backend large models or use the same large model uniformly. Specifically, the complete technical solution includes the following agents:

[0098] (1) Overall Control Agent. This agent is responsible for the overall planning, organization, and deployment of various R&D and self-testing tasks. It interacts with other agents through the MCP protocol. The overall control agent coordinates the cooperation of various sub-agents; for example, after sub-agent 4 returns a successful test case identifier, the overall control agent drives the operation of sub-agent 5.

[0099] (2) Source database compiled text recognition agent. Input the folder path corresponding to the source code into the source database compiled text recognition agent. The agent calls the utility function to scan the source files under the source code path, obtain the source code (i.e., static code) text of the source files, input the text into the backend large model, and extract the output query statement (i.e., source database compiled text), the number of lines of the query statement, the source code file name, the access path or URL corresponding to the query statement, and other information.

[0100] (3) Metadata Extraction Agent. Input query statement (the query statement here can be the query statement before transformation or the query statement after transformation). When the input is the text of the query statement before transformation, the agent inputs the text into the backend large model, extracts the table list information, and then calls the utility function to obtain the metatable information corresponding to each table in the source database and the target database, including but not limited to field names, field types, primary key names and primary key information, index names and index information, etc. Among them, the metatable information can be used in the input query statement transformation agent and the test case generation agent to improve the accuracy of the agent's output results.

[0101] (4) Compile the text conversion agent. Input the query statement before conversion (i.e., the compiled text), source / target database type and version information, and conversion direction information. This information is structured and organized using prompt word templates and then passed to the backend large model. The large model outputs the converted query statement. When inputting the meta-table information of the corresponding table in the target database type, the output will be more accurate.

[0102] (5) Test case generation of intelligent agents ( Figure 5 (The test agent is composed of several components). Input is a query statement (the transformed query statement, such as the compiled text to be tested for a T1 type database), source / target database type and version information, and transformation direction information. This information is then fed into the large model to generate test case programs, including but not limited to data preparation scripts, test case execution programs (i.e., the program under test), such as a call chain from Controller, Service, Dao, Mapper to the query statement, test case verification programs or scripts, and data recovery scripts. The large model returns text. After obtaining the returned text, the agent calls a program parsing tool to parse and generate program files and program manifest information. This tool is a preset program parsing engine used to organize the program text into an executable program file package according to a preset program design architecture.

[0103] (6) Case execution and report generation intelligent agent ( Figure 5(The components of the test agent in the process). The agent calls the script to start the test case program, generates a test case list based on the program list information generated in step (5), and calls the corresponding test entry point (such as the Controller, or the URL mapped to the Controller). The information returned by the controller is passed to the large model, which then transcribes it into a report and outputs it.

[0104] It may also include: (7) the target application output agent, which automatically performs application replacement based on the test results, until the application switching for the heterogeneous database is finally completed.

[0105] In summary, each intelligent agent performs its specific function and collaborates with others to automatically rewrite the front-end APP program and execute test verification cases corresponding to heterogeneous database switching. It should be noted that each of the aforementioned intelligent agents has pre-defined system prompts appropriate to its role, as well as corresponding parameter format definitions for dialogue input.

[0106] Regarding the test case generation agent in (5), it should be noted that the latest large-scale models in the industry are very powerful and can handle the current code transcription work based on the preset transcription prompts. However, directly updating the query statements transcribed by the large-scale model to the existing application will face huge risks. That is, if the transcribed query statements are wrong (including logical errors in the query statements, or the query statements themselves are not wrong, but errors occur when they are embedded in the application), it will cause significant losses. Therefore, this solution proposes to test and verify the transcribed query statements. Only the transcribed query statements that pass the verification will be updated or replaced in the existing application. (Here, there are multiple ways to update or replace: including: directly replacing the query statements in Dao.java or Mapper.XML, or updating the access URL, etc.).

[0107] For example, the core idea for testing and verifying query statement syntax transcribing is as follows:

[0108] Step 1: Identify the query operation type, which can be Delete, Insert, Update, Select, or Merge;

[0109] Step 2: Develop different test case execution strategies for different operation types, for example:

[0110] a) Delete: Insert case data -> Execute Gauss Delete -> Verify that the case data has been deleted.

[0111] b) Insert: Delete case data -> Execute Gauss Insert -> Verify that the case data has been inserted.

[0112] c) Update: Delete case data -> Insert case data -> Gauss Update -> Verify that the case data has been updated as expected.

[0113] d) Select: Delete case data -> Insert case data -> Gauss Select -> Verify that the retrieved data matches the original case data.

[0114] e) Merge: This is broken down into Insert and Update, and then the above execution flow is executed separately for each of the two operation types. (See diagram below.) Figure 4 As shown.

[0115] Humans follow the above approach when handling related tasks. When defining the intelligent agent (5), the above verification rules are built into the built-in system prompts for interacting with the large model.

[0116] Regarding test case generation and verification, transcription rules are defined in the system prompts. These rules include expert experience and optimize the behavior of the large model, thereby integrating the capabilities of the large model with expert experience. For example, verification rules are embedded into the built-in system prompts for large model interactions through text description rules. For instance, for the verification rule of insert, the embedded prompt is: "If the query statement type is DELETE, generate a new data record based on the meta-table information, i.e., test data, insert it into the database, call the transformed query statement to execute the deletion, delete the inserted test data, and verify whether the test data was successfully deleted."

[0117] For example, prompts can be optimized into structured logic text. Rules can be placed within the prompts of a large model in the form of a flowchart represented by structured logic text. Here, the structured logic text uses predefined syntactic keywords to identify test steps and the flow logic between steps. For general flowcharts (such as...) Figure 4 As shown, unstructured flowcharts in the form of images are generally converted into Mermaid flowcharts. This involves converting unstructured image formats into a text format that can be expressed using characters and understood by large models. Mermaid can represent flowcharts, sequence diagrams, timing diagrams, Gantt charts, class diagrams, and state diagrams, etc. For example, a flowchart can be expressed as the following text:

[0118] Table 4. Flowchart Representation of Structured Logical Text

[0119]

[0120] Table 4's Mermaid flowchart describes a "conditional judgment" business logic. The process steps are as follows: Enter the process from the "Start" node (A); enter the condition judgment node (B), and branch according to the condition result: If the condition is true: execute operation 1 (C), then enter the "End" node (E); If the condition is false: execute operation 2 (D), then enter the "End" node (E); The two branches eventually converge at the "End" node, and the process terminates. Although this text is not directly understandable to humans, the large model can, overcoming the bottleneck that non-multimodal large models cannot understand images. Furthermore, the large model is inherently a generative model of symbolic text type; representing prompts with structured logical text can improve the accuracy of test cases generated by the large model. Practice has also proven that using structured logical text based on the flowchart as prompts is more effective than using rules directly described in text.

[0121] In step (5), the test case agent returns text. This includes: ① a data preparation script, such as the data script for generating a delete command before testing insert; ② the text of the test case execution program, which is converted into a program file in the tool; and ③ a data verification script, used to execute the verification program, comparing the data of the target database after data preparation with the data of the target database after executing the test program, to determine whether the test program is executed accurately.

[0122] After the agent receives the text as described above, it calls a tool (such as a preset program parsing engine) to generate program files and program manifest information.

[0123] Specifically, the program files are as follows: the tool generates corresponding controller files from the formatted text returned by the agent, and organizes them according to the organizational structure of the program design architecture.

[0124] For example, the tool sequentially splits a text file into controller, service, dao, and mapper files, and then places these files into their respective controller, service, dao, and mapper folders to obtain a complete test and verification chain.

[0125] The agent invokes the script to start the test case program. Based on the program manifest information generated in step 5), it generates a test case list and calls the corresponding test entry point. The information returned by the controller is then passed to the large model, which transcribes it into report content for output.

[0126] Based on the report content, the verification results of the transcribed query statements are obtained. If the verification passes, the corresponding transcribed query statement is accepted. If it fails, the reasons for the failure are analyzed manually, and the query statement is transcribed manually.

[0127] If successful, the replacement strategy includes several options: for example, directly replacing the existing DAO file, or replacing the access URL of the validated query statement with the new URL. During the replacement process, a dynamic gradient replacement can be used to gradually transition from a non-domestic database to a domestic database.

[0128] According to the embodiments of this application, the beneficial effects include: 1) Reduced R&D costs. The intelligent agent solution can basically automate / semi-automatically realize the R&D work of switching heterogeneous databases, reducing the entire R&D team from more than ten people to only 1-2 people. 2) Improved R&D efficiency and shorter R&D cycle. This solution can achieve almost uninterrupted work, greatly improving R&D efficiency. 3) Good conversion accuracy and high quality. With the powerful code refactoring capabilities of the large model and the automated test case verification capabilities of the intelligent agent in the solution, the quality of work can be effectively guaranteed.

[0129] The embodiments of this application, by adopting a distributed intelligent agent collaborative architecture, realize an adaptive query statement transformation engine and dynamic metadata-driven reconstruction, digitize expert experience, and achieve highly available application switching for heterogeneous databases.

[0130] According to embodiments of this application, in addition to MCP, other protocols, or even custom protocols, can be used to implement the multi-agent interaction protocol. As long as interaction between agents can be achieved, the aforementioned effects can be realized. Program framework types or languages ​​include, but are not limited to, Java, Python, C++, etc.

[0131] Based on the above-described application switching method for heterogeneous databases, this application also provides an application switching device for heterogeneous databases. The following will combine... Figure 7 The device is described in detail.

[0132] Figure 7 The diagram illustrates a structural block diagram of an application switching device for heterogeneous databases according to an embodiment of this application.

[0133] like Figure 7 As shown, the application switching device 700 for heterogeneous databases in this embodiment includes an identification module 710, a conversion module 720, a testing module 730, and a target application determination module 740.

[0134] The identification module 710 is used to respond to a received heterogeneous database switching request, obtain the application static code of the source database involved in the switching request, extract data from the application static code, and obtain the compiled text of the source database. In one embodiment, the identification module 710 can be used to perform the operation S210 described above, which will not be repeated here.

[0135] The conversion module 720 is used to confirm the target database type involved in the switching request, map code compilation rules according to the target database type, and convert the source database compilation text into test compilation text adapted to the target database type based on the compilation rules. In one embodiment, the conversion module 720 can be used to perform the operation S220 described above, which will not be repeated here.

[0136] The testing module 730 is used to encapsulate the compiled text to be tested into a program to be tested based on a preset program design architecture, and to perform functional tests on the program to be tested based on preset test prompts to obtain test results. In one embodiment, the testing module 730 can be used to execute the operation S230 described above, which will not be repeated here.

[0137] The target application determination module 740 is used to, in response to the test result indicating that the program under test has passed the test, designate the compiled text under test as the target database compiled text corresponding to the target database, and designate the program under test as a component program of the target application. In one embodiment, the target application determination module 740 may be used to perform the operation S240 described above, which will not be repeated here.

[0138] According to an embodiment of this application, the test module 730 is further configured to encapsulate the compiled text to be tested based on meta-table information under the constraints of the program design architecture to generate an architecture component program file; wherein, the meta-table information includes field names, field types, index names and index types extracted from the compiled text to be tested; and configure the architecture component program file as an executable program to be tested based on the program startup configuration mapped according to the program design architecture.

[0139] According to an embodiment of this application, the testing module 730 is further configured to obtain the functional category of the program under test; wherein the functional category includes at least one of query, add, delete, update, and merge; to map functional test prompts in a preset functional test prompt library according to the functional category; the preset functional test prompt library includes a correspondence between multiple functional categories and functional test prompts, each functional test prompt being used to indicate the functional test process of the corresponding functional category; to perform data changes in the target database corresponding to the change prompts based on the change prompts of the functional test prompts, thereby obtaining the changed data in the target database; to call the call entry corresponding to the program under test based on the execution prompts of the functional test prompts, thereby executing the program under test to perform data operations on the changed data in the target database corresponding to the functional category, thereby obtaining the executed data in the target database; wherein the call entry is configured to: receive a call signal, and trigger parameter loading and program execution of the program under test according to the call signal; and to perform verification based on the verification prompts of the functional test prompts, based on the changed data and executed data in the target database, thereby using the verification result as the test result, wherein a verification result that matches the verification prompt indicates that the program under test has passed the test.

[0140] According to an embodiment of this application, the conversion module 720 is further configured to match the source table name in a preset data table mapping set to obtain the target table name under the corresponding target database. The preset data table mapping set stores the association relationship between the table names, source metatable information, target database table names, and target metatable information of multiple source databases, and stores the information mapping relationship between source metatable information and target metatable information. Based on the source metatable information, the corresponding target metatable information is mapped in the preset data table mapping set. Based on the code compilation rules, the source database compilation text is converted into test compilation text adapted to the target database type. During the conversion, the source table name in the source table data compilation text is replaced with the target table name, and the source metatable information is replaced with the corresponding target metatable information.

[0141] According to an embodiment of this application, the target application determination module 740 is further configured to identify the source program and source call entry point corresponding to the source database compilation text in the application static code; replace the source program corresponding to the source call entry point in the application static code with the program to be tested; and replace the source driver program used to connect the source program and the source database in the application component program with the target driver program used to connect the program to be tested and the target database to obtain the target application.

[0142] According to an embodiment of this application, the target application determination module 740 is further configured to identify the source call entry point of the source program corresponding to the source database compilation text in the static code of the application; replace the code in the static code of the application that calls the source call entry point with the code that calls the call entry point of the program under test; and replace the source driver program in the application component program that connects the source program and the source database with the target driver program that connects the program under test and the target database to obtain the target application.

[0143] According to an embodiment of this application, the application switching device for heterogeneous databases further includes a rollback module 750, which, in response to a received application rollback request for heterogeneous databases, replaces the code in the static code of the target application that calls the entry point of the program under test with the code that calls the entry point of the source program, and replaces the target driver in the component program of the target application that connects the program under test and the target database with the source driver that connects the source program and the source database, thereby obtaining the application.

[0144] According to embodiments of this application, any plurality of modules among the identification module 710, conversion module 720, testing module 730, and target application determination module 740 can be combined into one module, or any one of these modules can be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules can be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this application, at least one of the identification module 710, conversion module 720, testing module 730, and target application determination module 740 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the identification module 710, conversion module 720, testing module 730, and target application determination module 740 may be implemented at least partially as a computer program module that can perform corresponding functions when the computer program module is run.

[0145] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing an application switching method for heterogeneous databases according to an embodiment of this application.

[0146] like Figure 8As shown, an electronic device 800 according to an embodiment of this application includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage portion 808 into a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this application.

[0147] RAM 803 stores various programs and data required for the operation of electronic device 800. Processor 801, ROM 802, and RAM 803 are interconnected via bus 804. Processor 801 executes various operations of the method flow according to embodiments of this application by executing programs in ROM 802 and / or RAM 803. It should be noted that the programs may also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 may also execute various operations of the method flow according to embodiments of this application by executing programs stored in said one or more memories.

[0148] According to embodiments of this application, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to a bus 804. The electronic device 800 may also include one or more of the following components connected to the input / output (I / O) interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.

[0149] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.

[0150] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include ROM 802 and / or RAM 803 and / or one or more memories other than ROM 802 and RAM 803 described above.

[0151] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the application switching method for heterogeneous databases provided in the embodiments of this application.

[0152] When the computer program is executed by the processor 801, it performs the functions defined in the system / apparatus of this application embodiment. According to the embodiments of this application, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0153] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 809, and / or installed from a removable medium 811. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0154] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from the removable medium 811. When the computer program is executed by the processor 801, it performs the functions defined in the system of this application embodiment. According to the embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0155] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0157] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.

Claims

1. A method for switching applications to heterogeneous databases, characterized in that, The method includes: In response to receiving a heterogeneous database switching request, the application static code of the source database involved in the switching request is obtained, and data is extracted from the application static code to obtain the source database compiled text. Confirm the target database type of the target database involved in the switching request, map the code compilation rules according to the target database type, and convert the source database compilation text into test compilation text adapted to the target database type based on the code compilation rules; Based on the preset program design architecture, the compiled text to be tested is encapsulated into a program to be tested, and the program to be tested is functionally tested to obtain the test results. In response to the test result indicating that the program under test has passed the test, the compiled text under test is used as the target database compiled text corresponding to the target database, and the program under test is used as a component program of the target application.

2. The method according to claim 1, characterized in that, The process of encapsulating the compiled text to be tested into a program to be tested, based on a preset program design architecture, includes: Under the constraints of the program design architecture, the compiled text to be tested is encapsulated based on meta-table information to generate architecture component program files; wherein, the meta-table information includes field names, field types, index names and index types extracted from the compiled text to be tested; Based on the program design architecture mapping program startup configuration, the architecture component program files are configured as executable programs to be tested.

3. The method according to claim 2, characterized in that, The functional testing of the program under test yields test results, including: Obtain the function category of the program under test; wherein the function category includes at least one of query, add, delete, update, and merge; Functional test prompts are obtained by mapping the functional categories to a preset functional test prompt word library; the preset functional test prompt word library includes a correspondence between multiple functional categories and functional test prompts, and each functional test prompt is used to indicate the functional test process of the corresponding functional category; Based on the change prompts for functional test prompts, data changes corresponding to the change prompts are made in the target database to obtain the changed data in the target database; Based on the execution prompt words of the functional test prompt words, the call entry point corresponding to the program under test is called to execute the program under test, so as to perform data operations on the modified data of the target database in accordance with the functional category, and obtain the executed data of the target database; wherein, the call entry point is configured to: receive a call signal, and trigger the parameter loading and program execution of the program under test according to the call signal; Based on the verification prompts of the functional test prompts, verification is performed on the modified data and the executed data in the target database corresponding to the verification prompts. The verification result is used as the test result, wherein a verification result that matches the verification prompts indicates that the program under test has passed the test.

4. The method according to claim 1, characterized in that, The process of converting the source database compiled text into test compiled text adapted to the target database type based on the code compilation rules includes: Extract source table names and source meta-table information from the source database compiled text; Based on the source table name, the target table name under the corresponding target database is obtained by matching in the preset data table mapping set. The preset data table mapping set stores the association relationship between the table names of multiple source databases, source meta table information, target database table names, and target meta table information, and stores the information mapping relationship between source meta table information and target meta table information. Based on the source meta-table information, the corresponding target meta-table information is obtained by mapping in a preset data table mapping set; Based on the code compilation rules, the source database compilation text is converted into test compilation text adapted to the target database type. During the conversion, the source table name in the source table data compilation text is replaced with the target table name, and the source metatable information is replaced with the corresponding target metatable information.

5. The method according to claim 1, characterized in that, The program that uses the program under test as a component of the target application includes: Identify the source program and source call entry point corresponding to the compiled text of the source database in the static code of the application. Replace the source program corresponding to the source call entry point in the static code of the application with the program under test, and replace the source driver program in the application component program that connects the source program and the source database with the target driver program that connects the program under test and the target database to obtain the target application.

6. The method according to claim 1, characterized in that, The program that uses the program under test as a component of the target application includes: Identify the source call entry point of the source program corresponding to the compiled text of the source database in the static code of the application; Replace the code that calls the source entry point in the static code of the application with the code that calls the entry point of the program under test, and replace the source driver in the application component program that connects the source program and the source database with the target driver that connects the program under test and the target database to obtain the target application.

7. The method according to claim 6, characterized in that, The method further includes: In response to a received application rollback request for a heterogeneous database, the code in the static code of the target application used to call the program under test is replaced with the code in the static code used to call the source program, and the target driver in the component program of the target application used to connect the program under test and the target database is replaced with the source driver used to connect the source program and the source database, thus obtaining the application.

8. An application switching device for heterogeneous databases, characterized in that, The device includes: The identification module is used to respond to a received heterogeneous database switching request, obtain the application static code of the source database involved in the switching request, extract data from the application static code, and obtain the source database compiled text. The conversion module is used to confirm the target database type of the target database involved in the switching request, map code compilation rules according to the target database type, and convert the source database compilation text into test compilation text adapted to the target database type based on the code compilation rules; The testing module is used to encapsulate the compiled text under test into a program under test based on a preset program design architecture, and to perform functional tests on the program under test based on preset test prompts, thereby obtaining test results; and The target application determination module is used to, in response to the test result indicating that the program under test has passed the test, designate the compiled text under test as the target database compiled text corresponding to the target database, and designate the program under test as a component program of the target application.

9. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.