Database switching method and system, electronic equipment and storage medium

By presetting multiple data sources and automatically identifying task parameters, the workflow engine can flexibly adapt and dynamic switching of multiple databases, solving the complexity and instability problems caused by database differences in the existing technology, and improving the flexibility and stability of database switching.

CN119622036APending Publication Date: 2025-03-14CISDI INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411705510.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

The prior art is difficult to achieve flexible adaptation and dynamic switching of multiple types of databases in workflow engines, especially the complexity and instability problems caused by differences in data models, SQL syntax and transaction processing mechanisms.

Method used

By pre-setting multiple data sources of the application and obtaining task parameters in the workflow, we can automatically identify and adapt different databases, instantiate corresponding process engine instances, and dynamic data source switching is performed when the workflow is called.

Benefits of technology

Adaptive dynamic database switching is realized, improving the flexibility, stability and accuracy of database switching, and ensuring seamless switching and efficient operation of business processes between different databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119622036A_ABST
    Figure CN119622036A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of database management, and discloses a database switching method and system, electronic equipment and a storage medium, the method comprises the following steps: obtaining a workflow corresponding to an application program, selecting a target source corresponding to each task parameter from a plurality of data sources, each task parameter is acquired, instantiation is performed according to each task parameter, process engine instances corresponding to each target source are acquired, each data source is a plurality of data sources corresponding to a preset application program, any target source is called in response to the workflow, and data source switching is performed according to the process engine instance corresponding to the target source; according to the method, the more practical and more accurate database switching method is provided, the target source corresponding to the task parameter is determined from the multiple data sources corresponding to the application program, data source switching is conducted through the process engine instance corresponding to the target source, self-adaptive dynamic database switching is achieved, and the flexibility and stability of database switching are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of database management, and in particular to a database switching method, system, electronic device and storage medium. Background Art

[0002] In the current information innovation environment and actual business scenarios, application systems are faced with the need to adapt to various types of databases, especially domestic databases. Information innovation aims to promote the development of the domestic information technology industry and emphasizes the application of independent and controllable information technology. With the in-depth implementation of information innovation policies and the rapid development of domestic databases, how to achieve comprehensive support for these databases at the application level has become an urgent problem to be solved.

[0003] Although there are solutions for multi-data source configuration and dynamic switching in the relevant technology, most of these solutions are limited to simple switching of the data access layer, that is, selecting a specific data source for read and write operations at runtime according to preset rules or conditions. However, this switching method fails to support the dynamic adaptation of the workflow engine well. As the core component of business process automation, the workflow engine has higher complexity and dynamic requirements, and needs to be able to be flexibly configured and adjusted according to different database characteristics. In addition, in practical applications, the differences between different database types, such as data models, SQL syntax, transaction processing mechanisms, etc., make the configuration and management of the workflow engine more complicated. These differences not only increase the workload of development and maintenance, but may also cause errors or instability in the business process during execution. Obviously, there is an urgent need for a new database switching method to solve at least one of the above problems.

[0004] It should be noted that the above content only provides background technical information related to the present application and does not necessarily constitute prior art. Summary of the invention

[0005] In view of the above-mentioned shortcomings of the prior art, the present application provides a database switching method, system, electronic device and storage medium to achieve adaptive dynamic switching of databases and improve the flexibility and stability of database switching.

[0006] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0007] According to one aspect of an embodiment of the present application, a database switching method is provided, comprising: obtaining a workflow corresponding to an application, wherein the workflow includes one or more task parameters; selecting a target source corresponding to each of the task parameters from a plurality of data sources, and instantiating them according to each of the task parameters to obtain a process engine instance corresponding to each of the target sources, wherein each of the data sources is a plurality of data sources pre-set to correspond to the application; in response to the workflow calling any target source, switching the data source according to the process engine instance corresponding to the target source.

[0008] In one embodiment of the present application, based on the aforementioned scheme, multiple data sources corresponding to the application are pre-set in the following manner: obtaining connection information of multiple databases corresponding to the application; configuring the multiple data sources corresponding to the application based on the connection information and a preset configuration method, wherein the preset configuration method includes writing the connection information in the application, or writing the connection information into a configuration file corresponding to each of the data sources.

[0009] In one embodiment of the present application, based on the aforementioned scheme, after pre-setting multiple data sources corresponding to the application, the method further includes: instantiating each of the data sources to obtain a data source instance corresponding to each of the data sources, the data source instance being used to manage the connection status of each of the databases; storing each of the data source instances to a first preset storage location, respectively, to run each of the data source instances at the first preset storage location; and adding access information of each of the data source instances to a preset global routing table, respectively, for scheduling by a data source router, the data source router being used to determine the target source corresponding to the task parameters.

[0010] In one embodiment of the present application, based on the aforementioned scheme, target sources corresponding to each of the task parameters are selected from multiple data sources, including: extracting matching parameters corresponding to each of the task parameters from each of the task parameters, the matching parameters including at least one of a user identifier, a process node, business information, and a configuration parameter; matching parameters corresponding to each of the task parameters are matched with each of the data sources, and determining target sources corresponding to each of the task parameters from each of the data sources based on the matching results, wherein there is a corresponding relationship between the matching parameters and the data sources.

[0011] In one embodiment of the present application, based on the aforementioned scheme, after selecting the target sources corresponding to each of the task parameters from a plurality of data sources, the method further includes: determining the data source type of each of the target sources according to each of the task parameters, and generating the process engine instances corresponding to each of the target sources based on the data source type of each of the target sources; storing each of the process engine instances to a second preset storage location for scheduling by a process engine instance scheduler, the process engine instance scheduler being used to manage and schedule process engine instances corresponding to different databases; storing each of the process engine instances to a preset monitoring location to monitor each of the process engine instances.

[0012] In one embodiment of the present application, based on the aforementioned scheme, in response to the workflow calling any target source, it includes: determining the target source currently called by the workflow based on the current task parameters of the workflow; and calling the target source currently called by the workflow based on the connection information corresponding to the target source currently called by the workflow.

[0013] In one embodiment of the present application, based on the aforementioned scheme, in response to the workflow calling any target source, before the method further includes: obtaining the priority of each of the task parameters; determining the scheduling priority of each of the target sources based on the priority of each of the task parameters; and calling the target source according to the scheduling priority.

[0014] According to one aspect of an embodiment of the present application, a database switching system is provided, comprising: an acquisition module, used to acquire a workflow corresponding to an application, wherein the workflow includes one or more task parameters; a selection module, used to select a target source corresponding to each of the task parameters from a plurality of data sources, and instantiate according to each of the task parameters to obtain a process engine instance corresponding to each of the target sources, wherein each of the data sources is a plurality of data sources pre-set to correspond to the application; and an execution module, used to switch the data source according to the process engine instance corresponding to the target source in response to the workflow calling any target source.

[0015] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements a database switching method as described in any one of the above embodiments.

[0016] The present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer, the computer is enabled to execute the database switching method as described in any one of the above embodiments.

[0017] Beneficial effects of the present application: The present application obtains the workflow corresponding to the application by pre-setting multiple data sources corresponding to the application, wherein the workflow includes one or more task parameters, selects the target source corresponding to each task parameter from each data source, automatically identifies and adapts different databases through task parameters, and instantiates them according to each task parameter to obtain the process engine instance corresponding to each target source, responds to the workflow calling any target source, switches the data source according to the process engine instance corresponding to the target source, realizes adaptive dynamic switching of databases, improves the flexibility, stability and accuracy of database switching, and thereby realizes seamless switching and efficient operation of business processes between different databases.

[0018] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0020] Figure 1 is a schematic diagram of an exemplary system architecture shown in an exemplary embodiment of the present application;

[0021] Figure 2 is a flowchart of a database switching method shown in an exemplary embodiment of the present application;

[0022] Figure 3 is a flowchart of a database switching method shown in another exemplary embodiment of the present application;

[0023] Figure 4 is a block diagram of a database switching system shown in an exemplary embodiment of the present application;

[0024] Figure 5 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0025] The following will describe the implementation methods of the present application with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, not for limiting the scope of protection of the present application.

[0026] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present application in a schematic manner, and therefore the illustrations only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0027] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present application difficult to understand.

[0028] First of all, it should be noted that the Xinchuang environment is the abbreviation of "Information Technology Application Innovation Environment", which refers to the country building its own information technology industry standards and ecology, so that IT (Information Technology) products and technologies are safe and controllable, and get rid of dependence on foreign IT standards. The Xinchuang environment includes four major sections: basic hardware, basic software, application software and information security. Basic hardware mainly includes chips, servers, storage, etc.; basic software includes databases, operating systems, middleware, etc.; application software includes office software, ERP (Enterprise Resource Planning, Enterprise Management Information System) and other software; information security includes hardware security, software security, security services and other products. The development of the Xinchuang environment is conducive to domestic enterprises to complete the digital transformation of enterprises under the background of building a "Digital China" to cope with international competition in the next few decades. At the same time, the development of Xinchuang is also to support domestic enterprises in the field of Xinchuang, help improve R&D capabilities and talent reserves, drive economic growth, drive employment, and achieve sustainable development.

[0029] Workflow Engine refers to workflow as a part of the application system, and provides core solutions for each application system, such as determining information transmission routing, content level, etc. according to different roles, division of labor and conditions. Workflow Engine includes important functions such as process node management, flow management, process sample management, etc.

[0030] Workflow refers to the automation of part or all of a business process in a computer application environment. It is an abstract and general description of the workflow and the business rules between its various operation steps. In computers, workflow is part of computer-supported collaborative work (CSCW). The latter generally studies how a group can achieve collaborative work with the help of computers.

[0031] Figure 1 It is a schematic diagram of an exemplary system architecture shown in an exemplary embodiment of the present application.

[0032] Reference Figure 1 As shown, the system architecture may include a data acquisition device 101 and a computer device 102. The computer device 102 may be at least one of a desktop graphics processing unit (GPU) computer, a GPU computing cluster, a neural network computer, etc. The data acquisition device 101 is used to obtain the workflow corresponding to the application, wherein the workflow includes one or more task parameters. In this embodiment, the data acquisition device 101 obtains the above data and provides it to the computer device 102 for processing. Relevant technicians can use the computer device 102 to pre-set multiple data sources corresponding to the application, select the target source corresponding to each task parameter from each data source, and instantiate it according to each task parameter to obtain the process engine instance corresponding to each target source, and respond to the workflow calling any target source, and switch the data source according to the process engine instance corresponding to the target source. It should be noted that the data acquisition device 101 and the computer device 102 provided in this embodiment are only an example, and should not bring any limitation to the function and scope of use of the embodiment of the present application.

[0033] It should be noted that the database switching method provided in the embodiment of the present application is generally executed by the computer device 102 , and accordingly, the database switching system is generally disposed in the computer device 102 .

[0034] Figure 2 is a flowchart of a database switching method shown in an exemplary embodiment of the present application. The database switching method can be executed by a computing and processing device. The computing and processing device can be Figure 1 The computer device 102 shown in FIG. Figure 2As shown, the database switching method at least includes steps S210 to S230, which are described in detail as follows:

[0035] In step S210, the workflow corresponding to the application is obtained.

[0036] In one embodiment of the present application, a workflow corresponding to an application is defined and obtained through a workflow engine, wherein the workflow includes one or more task parameters. Wherein, the workflow engine is a software system responsible for defining, executing and managing workflows, which are composed of a series of interrelated business activities, which are organized in a specific order and rules to achieve specific business goals. The workflow engine allows users to define workflows through a visual interface or programmatically. This usually includes specifying the order of tasks, setting dependencies between tasks, defining trigger conditions, and assigning tasks to specific users or roles. Through the workflow engine, users can create complex workflows and apply them to applications to achieve automated management of business processes.

[0037] In step S220, target sources corresponding to the task parameters are selected from a variety of data sources, and instantiation is performed according to the task parameters to obtain process engine instances corresponding to the target sources.

[0038] In one embodiment of the present application, the process of selecting target sources corresponding to each task parameter from multiple data sources includes the following steps: extracting matching parameters corresponding to each task parameter from each task parameter, the matching parameters including at least one of user identification, process node, business information and configuration parameters; matching the matching parameters corresponding to each task parameter with each data source, and determining the target source corresponding to each task parameter from each data source based on the matching results, wherein there is a corresponding relationship between the matching parameters and the data source. The specific corresponding relationship is preset, for example, when the user identification is preset to X, the corresponding data source is A, and for another example, when the process node is preset to a, the corresponding data source is B. The efficiency and accuracy of determining the target source are improved by automatically identifying and adapting different databases through task parameters.

[0039] In this embodiment, the task parameters include database information, the database information includes the database name, and the database connection information also includes the database name. Therefore, the corresponding target connection information can be determined according to the database name in the task parameters, and the target source corresponding to the task parameters can be determined from the data source according to the target connection information.

[0040] In one embodiment of the present application, the process after selecting the target source corresponding to each task parameter from multiple data sources also includes the following steps: determining the data source type of each target source according to each task parameter, generating a process engine instance corresponding to each target source based on the data source type of each target source, the process engine instance is used to complete the task corresponding to the task parameter based on the task parameter, including operating the database corresponding to the target source through the process engine instance (for example, adding, deleting, modifying and searching the data in the database, etc.); storing each process engine instance in a second preset storage location for scheduling by a process engine instance scheduler, the process engine instance scheduler is used to manage and schedule process engine instances corresponding to different databases; storing each process engine instance in a preset monitoring location to monitor each process engine instance, such as the survival status and resource consumption status of each process engine instance.

[0041] In this embodiment, a process engine instance scheduler is implemented to manage and schedule process engine instances corresponding to different databases. When the application switches to a different data source, the process engine instance that should be used currently, i.e., the process engine instance corresponding to the target source, is uniformly scheduled through the process engine instance scheduler. When the process engine needs to be used, the process engine instance scheduler obtains the corresponding process engine instance from the second preset storage location in the memory according to the current data source, i.e., the target source corresponding to the current task parameters. By uniformly scheduling the process engine instance that should be used currently for data operations through the process engine instance scheduler, it can be ensured that when switching between different data sources, the instance of the workflow engine can be correctly scheduled and used.

[0042] In one embodiment of the present application, multiple data sources corresponding to the application are pre-set in the following manner: obtaining connection information of multiple databases corresponding to the application; configuring multiple data sources corresponding to the application based on the connection information and a preset configuration method, wherein the preset configuration method includes writing the connection information in the application, or writing the connection information into a configuration file corresponding to each data source. The multiple databases corresponding to the application refer to databases of multiple database types corresponding to the application, including but not limited to MySQL, DAMO, Renmin University of China Golden Warehouse and other databases.

[0043] In one embodiment, the process of configuring the data source according to the connection information of the database includes some or all of the following steps:

[0044] Step 1: Obtain and confirm the database connection information, which includes the address of the database server (which may be the host name or IP address), port number, database name, user name and password for authentication, etc.

[0045] Step 2: Choose the data source configuration method: Determine how to configure the data source based on the programming language and framework used. This may involve editing configuration files (such as XML, JSON, etc.) or setting data source parameters directly in the code.

[0046] Step 3. Edit or create a configuration file and fill in the connection information in the configuration file: If you choose to set the data source through a configuration file, you need to find or create a target configuration file and add or update the database connection information in it. In the configuration file, accurately fill in the database connection information according to the format requirements of the selected framework or library. This usually includes specifying the database type, server address, port number, database name, user name and password, etc. Alternatively, set the data source in code: If you choose to configure the data source directly in code, you need to add the corresponding code in the initialization part of the application to create and configure the data source object.

[0047] Step 4: Verify the data source configuration: After the configuration is complete, verify the correctness of the data source configuration by running the application and trying to access the database. If the connection is successful, it means that the data source configuration is correct; if the connection fails, you need to check whether the connection information is filled in correctly or whether there are other configuration problems.

[0048] Step 5. Handle exceptions and errors: When trying to connect to the database, you should properly handle possible exceptions and errors, including capturing exceptions for connection failures and recording detailed error information for troubleshooting.

[0049] Step 6: Deployment and monitoring: Once the data source is successfully configured and verified, it can be deployed to the production environment. At the same time, a monitoring mechanism should be established to track the performance and stability of the data source so that problems can be discovered and resolved in a timely manner.

[0050] Step 7: Protect sensitive information: When configuring data sources, special attention should be paid to protecting sensitive information (such as database passwords). This can be achieved by using encryption technology, environment variables, or configuration file management tools.

[0051] Step 8: Update and maintain: As the application and database environment change, the data source configuration may need to be updated regularly. Therefore, a corresponding update and maintenance process should be established to ensure that the data source configuration is always consistent with the current environment.

[0052] It should be noted that this embodiment is only an example of the process of configuring a data source according to the connection information of a database. The above steps can be modified or deleted as needed, and this application does not impose any restrictions on this.

[0053] In one embodiment of the present application, the process after presetting the multiple data sources corresponding to the application further includes the following steps: instantiating each data source to obtain a data source instance corresponding to each data source, the data source instance is used to manage the connection status of each database, and the data source instance is also used to execute SQL statements (structured query language statements), including operations such as query, insert, update and delete, and the data source instance sends the SQL statement to the database server and processes the returned results; storing each data source instance in a first preset storage location to run each data source instance in the first preset storage location; adding the access information of each data source instance to a preset global routing table for scheduling by a data source router, and the data source router is used to determine the target source corresponding to the task parameters. Among them, one data source instance corresponds to one database type, and one data source instance can correspond to a cluster composed of multiple database connections.

[0054] In step S230, in response to the workflow calling any target source, the data source is switched according to the process engine instance corresponding to the target source.

[0055] In one embodiment of the present application, before the workflow calls any target source, it includes: determining the target source currently called by the workflow based on the current task parameters of the workflow; and calling the target source currently called by the workflow based on the connection information corresponding to the target source currently called by the workflow.

[0056] In this embodiment, in response to a workflow calling a target source currently called by the workflow, a data source is switched according to a process engine instance corresponding to the target source currently called by the workflow, which can flexibly adapt to different types of database problems.

[0057] In one embodiment of the present application, before the workflow calls any target source, the method also includes: obtaining the priority of each task parameter; determining the scheduling priority of each target source based on the priority of each task parameter; and calling the target source according to the scheduling priority. Calling the target source according to the scheduling priority can improve the system response speed: by giving priority to high-priority tasks, it can ensure that key business operations or user requests are responded to quickly, thereby improving user experience and system performance; it can optimize resource utilization: scheduling priority can help the system allocate resources more effectively. For example, when resources are tight, low-priority tasks can be postponed or restricted to ensure that high-priority tasks have enough resources to execute; it can enhance system stability: by setting priorities reasonably, it can prevent certain tasks (such as large-scale data import or complex query) from occupying too many resources and causing system crashes or performance degradation; it can support business priorities: different business operations may have different importance. For example, transaction requests of real-time trading systems usually have higher priority than batch data updates. Through priority scheduling, it can ensure that key business operations are given priority; it can reduce waiting time and delay: prioritizing high-priority tasks can reduce the waiting time and execution delay of these tasks, thereby improving the efficiency and throughput of the overall system; it can provide a better user experience: for user-oriented applications, fast response is the key. By giving priority to user requests (such as queries, updates, etc.), the user experience can be significantly improved, and user satisfaction and loyalty can be increased.

[0058] In one embodiment, the data source can be switched through the process engine instance corresponding to the target source. For example, data is obtained from the A1 database and the A2 database respectively and stored in the B1 database, wherein the database types of the A1 database and the A2 database are the same, the data sources of the A1 database and the A2 database are A, and the data source of the B1 database is B. Then, the data source is switched through the process engine instance corresponding to the target source A, switched to the data source A, and the required target data is obtained from the A1 database and the A2 database, and then the data source is switched through the process engine instance corresponding to the target source B, switched to the data source B, and the target data is stored in the B1 database. It can be understood that this embodiment is only for illustrative purposes, and the present application does not limit the corresponding content in this embodiment, and should not bring any limitations to the functions and scope of use of the embodiments of the present application.

[0059] This application configures multiple data sources in the application, each data source corresponds to a different database, such as MySQL database, DAMO database, Renmin University of China Jincang database, etc., instantiates the process engine according to the configuration information of different databases, and adds the instance to the global routing table of the process engine to facilitate the scheduling and use of the process engine scheduler. By defining dynamic data source routers, dynamic routing of data sources is realized, and data sources are dynamically switched at runtime according to conditions such as request parameters or user information. When the business uses the process engine, the process engine scheduler can automatically identify the current data source type and construct a process engine instance that adapts to the current data source type, thereby realizing the process engine's support for dynamic switching of multiple different databases. It provides the ability for the workflow engine to automatically identify and adaptively switch between different types of databases in the same application.

[0060] Figure 3 is a flowchart of a database switching method shown in another exemplary embodiment of the present application, referring to Figure 3 As shown, the database switching method at least includes steps S1 to S4, which are described in detail as follows:

[0061] In step S1, multiple data sources are configured and instantiated. The connection information of multiple database types supported by the application is obtained, such as the DAMO database, the RDK Golden Warehouse database, and other database types. Based on the obtained database connection information, multiple data sources are configured, and each data source is instantiated and stored in memory.

[0062] In step S2, the data source is switched dynamically according to the context. During the operation of the system, according to the task parameters of the workflow, wherein the task parameters include one or more matching parameters, the matching parameters include but are not limited to at least one of user identification, process node, business information, user request and configuration parameters, wherein the business information includes business logic, business requirements and business type, and the configuration parameters include configuration policies; according to the matching parameters corresponding to the task parameters, the currently used data source, i.e., the target source corresponding to the current task parameters, is dynamically determined. A dynamic data source router is implemented, which is responsible for selecting a suitable data source, i.e., the target source, according to the context or configuration policy.

[0063] In step S3, the current data source type is automatically identified. A process engine configuration factory is defined to dynamically create and manage process engine instances. The process engine configuration factory automatically identifies the current data source type, dynamically generates the corresponding process engine instances, and caches these process engine instances in memory.

[0064] In step S4, the process engine instance is scheduled according to the current data source type. According to the currently switched data source, ie, the target source, the process engine instance corresponding to the current data source, ie, the current target source, is selected by the process engine instance scheduler to perform process database operations.

[0065] In one embodiment of the present application, the present application provides a method for adaptively and dynamically switching databases in workflows under an information-based innovation environment, including: configuring multiple data sources in an application to support different types of databases, including domestic databases, such as the DAMO database, the Renmin University of China Golden Warehouse database, etc. The connection information of different databases is configured and managed through configuration files. A dynamic data source routing mechanism is implemented in the application to dynamically select the data source required for the current operation based on business logic or tenant information. Use a dynamic data router to dynamically switch to the appropriate data source instance. Configure an independent workflow engine instance for each data source and manage it through a configuration factory. Ensure that the process engine instance corresponding to each database can be initialized and configured correctly. During the program running process, the corresponding process engine instance is uniformly scheduled to perform data operations through the process engine instance scheduler according to the current data source. Ensure that the instance of the workflow engine can be correctly scheduled and used when switching between different data sources. For the specific implementation process, refer to the following description:

[0066] Get the connection information of multiple supported database types, configure multiple data sources based on the obtained database connection information, instantiate each data source, get the data source instance, and store the data source instance in memory. The data source instance itself will run in memory, and add the instance access information to the global routing table for dynamic data source router scheduling. One data source instance can correspond to a cluster consisting of multiple actual database connections.

[0067] Implement a dynamic data source router, which is responsible for selecting the appropriate data source based on the context or configuration policy. The dynamic data source router dynamically routes to the corresponding data source, i.e., the target source, by matching parameters, including context information (such as user ID, i.e., user identification, business type, etc.) or configuration policies, thereby achieving smooth switching of different types of databases in a system according to different users or different business scenarios. The database type includes a trusted database, i.e., a domestic database.

[0068] Define the process engine configuration factory to dynamically create and manage process engine instances. The process engine configuration factory automatically identifies the current data source type, dynamically generates the corresponding process engine instances, caches these process engine instances in memory, and monitors the instantiated process engines in memory to obtain monitoring results, such as instance survival, resource consumption, etc.

[0069] Implement the process engine instance scheduler to manage and schedule process engine instances corresponding to different databases. When the program switches to a different data source, the process engine instance that should be used is uniformly scheduled through the process engine instance scheduler. When the process engine needs to be used, the process engine instance scheduler obtains the corresponding process engine instance from the memory according to the current data source.

[0070] The above method can realize adaptive dynamic switching of multiple databases of the workflow system in a trusted computing environment, improve the flexibility and stability of the system, and provide a solution that supports multiple types of databases in a comprehensive trusted computing environment, ensuring the efficient operation of the workflow engine when switching between different databases.

[0071] This application also has good scalability and maintainability to meet the high requirements of multiple users for flexibility and scalability. It can effectively reduce the difficulty of database adaptation for multiple users in the information and innovation environment and improve the automation level and operation efficiency of business processes.

[0072] Figure 4 is a block diagram of a database switching system shown in an exemplary embodiment of the present application. The system can be applied to Figure 1 The implementation environment shown in the figure is specifically configured in the computer device 102. The system can also be applied to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the system is applicable.

[0073] like Figure 4 As shown, the exemplary database switching system includes: an acquisition module 410 , a selection module 420 and an execution module 430 .

[0074] Among them, the acquisition module 4110 is used to obtain the workflow corresponding to the application, wherein the workflow includes one or more task parameters; the selection module 420 is used to select the target source corresponding to each task parameter from multiple data sources, and instantiate according to each task parameter to obtain the process engine instance corresponding to each target source, wherein each data source is a plurality of data sources corresponding to the pre-set application; the execution module 430 is used to respond to the workflow calling any target source and switch the data source according to the process engine instance corresponding to the target source.

[0075] It should be noted that the database switching system provided in the above embodiment and the database switching method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here. In practical applications, the database switching system provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the system into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0076] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the electronic device implements the database switching method provided in the above-mentioned embodiments.

[0077] Figure 5 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Figure 5 The computer system 500 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0078] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503, such as executing the methods provided in the above-mentioned various embodiments. In the RAM 503, various programs and data required for system operation are also stored. The CPU 501, the ROM 502 and the RAM 503 are connected to each other through the bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.

[0079] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that a computer program read therefrom is installed into the storage section 508 as needed.

[0080] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 509, and / or installed from a removable medium 511. When the computer program is executed by a central processing unit (CPU) 501, various functions defined in the system of the present application are executed.

[0081] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0082] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0083] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0084] Another aspect of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the database switching method provided in the above embodiments. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently without being assembled into the electronic device.

[0085] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0086] Another aspect of the present application also provides a computer program product or a computer program, the computer program product or the computer program includes a computer instruction, the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the database switching method provided in each of the above embodiments.

[0087] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.

[0088] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0089] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.

Claims

1. A database switching method, characterized in that: include: Acquire a workflow corresponding to the application, wherein the workflow includes one or more task parameters; Selecting target sources corresponding to each of the task parameters from a plurality of data sources, and instantiating them according to each of the task parameters to obtain process engine instances corresponding to each of the target sources, wherein each of the data sources is a plurality of data sources pre-set to correspond to the application; In response to the workflow calling any target source, a data source is switched according to a process engine instance corresponding to the target source.

2. The database switching method according to claim 1, characterized in that: Pre-set various data sources corresponding to the application in the following ways: Obtain connection information of multiple databases corresponding to the application; The multiple data sources corresponding to the application are configured based on the connection information and a preset configuration method, wherein the preset configuration method includes writing the connection information into the application, or writing the connection information into a configuration file corresponding to each of the data sources.

3. The database switching method according to claim 2, characterized in that: After presetting the multiple data sources corresponding to the application, the method further includes: Instantiate each of the data sources to obtain a data source instance corresponding to each of the data sources, wherein the data source instance is used to manage the connection status of each of the databases; storing each of the data source instances in a first preset storage location respectively, so as to run each of the data source instances in the first preset storage location; The access information of each of the data source instances is added to a preset global routing table for scheduling by a data source router, and the data source router is used to determine the target source corresponding to the task parameters.

4. The database switching method according to claim 1, characterized in that: Selecting target sources corresponding to the task parameters from a variety of data sources, including: Extracting matching parameters corresponding to the task parameters from the task parameters respectively, wherein the matching parameters include at least one of a user identifier, a process node, business information and a configuration parameter; Matching parameters corresponding to each of the task parameters are matched with each of the data sources respectively, and based on the matching results, target sources corresponding to each of the task parameters are determined from each of the data sources, wherein there is a corresponding relationship between the matching parameters and the data sources.

5. The database switching method according to any one of claims 1 to 4, characterized in that: After selecting the target sources corresponding to the task parameters from the multiple data sources, the method further includes: Determine the data source type of each target source according to each task parameter, and generate a process engine instance corresponding to each target source based on the data source type of each target source; Each of the process engine instances is stored in a second preset storage location for scheduling by a process engine instance scheduler, wherein the process engine instance scheduler is used to manage and schedule process engine instances corresponding to different databases; Each of the process engine instances is stored in a preset monitoring location to monitor each of the process engine instances.

6. The database switching method according to any one of claims 1 to 4, characterized in that: Before calling any target source in response to the workflow, the method includes: Determine the target source currently called by the workflow based on the current task parameters of the workflow; The target source currently called by the workflow is called based on the connection information corresponding to the target source currently called by the workflow.

7. The database switching method according to any one of claims 1 to 4, characterized in that: Before the workflow calls any target source, the method further includes: Obtaining the priority of each of the task parameters; Determining the scheduling priority of each of the target sources based on the priority of each of the task parameters; The target source is called according to the scheduling priority.

8. A database switching system, characterized in that: include: An acquisition module, used to acquire a workflow corresponding to an application, wherein the workflow includes one or more task parameters; A selection module is used to select target sources corresponding to each of the task parameters from multiple data sources, and instantiate them according to each of the task parameters to obtain process engine instances corresponding to each of the target sources, wherein each of the data sources is a plurality of data sources corresponding to the application program that is pre-set; The execution module is used to switch the data source according to the process engine instance corresponding to the target source in response to the workflow calling any target source.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enables the electronic device to implement the database switching method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of a computer, the computer is caused to execute the database switching method according to any one of claims 1 to 7.