Database communication methods, devices, equipment and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-27
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]本发明提供了一种数据库通信方法、装置、设备及存储介质,以解决现有技术存在的基于方言包无法完全消除数据库之间的通信障碍的问题
[0019]根据本发明的另一方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现本发明任一实施例所述的数据库通信方法。
Smart Images

Figure CN116303365B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database communication technology, and in particular to a database communication method, apparatus, device, and storage medium. Background Technology
[0002] Currently, all server-side applications are based on a single database for data persistence, with different applications accessing the database using different SQL (Structured Query Language) dialects. Over years of iteration, many server-side applications have accumulated a massive number of SQL statements. These statements are executed using ORM (Object-Relational Mapping) frameworks like Mybatis (formerly iBatis) and JPA (Java Persistence API), as well as hard-coded JDBC (Java Database Connect) drivers. When business requirements change and adaptation to other database types is needed, these SQL dialect statements must be modified and validated specifically to provide different application versions. While frameworks like JPA can improve SQL compatibility through dialect packages, not all databases proactively provide dialect packages for various ORM frameworks.
[0003] Furthermore, in the process of implementing the embodiments of the present invention, the applicant discovered that dialect packs cannot completely eliminate communication barriers between databases. Summary of the Invention
[0004] This invention provides a database communication method, apparatus, device, and storage medium to solve the problem that existing technologies based on dialect packets cannot completely eliminate communication barriers between databases.
[0005] According to one aspect of the present invention, a database communication method is provided, comprising:
[0006] Intercept the processing statement to be received by the target component, the processing statement being output by the output component;
[0007] The setting keyword in the processing statement is determined, and the processing strategy corresponding to the setting keyword is determined in the target configuration file, wherein the target configuration file includes the setting keyword and the processing strategy corresponding to the setting keyword;
[0008] When the processing strategy includes a database modification strategy, the corresponding configuration information in the database corresponding to the target component is modified according to the database modification strategy;
[0009] Release the processing statement so that it is sent to the target component, and the target component executes the processing statement based on the modified configuration information.
[0010] According to another aspect of the present invention, a database communication device is provided, comprising:
[0011] The acquisition module is used to intercept the processing statement to be received by the target component, and the processing statement is output by the output component;
[0012] The keyword determination module is used to determine the set keyword in the processing statement and to determine the processing strategy corresponding to the set keyword in the target configuration file. The target configuration file includes the set keyword and the processing strategy corresponding to the set keyword.
[0013] The information modification module is used to modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy when the processing strategy includes a database modification strategy;
[0014] The release module releases the processing statement so that the processing statement is sent to the target component, and the target component executes the processing statement based on the modified configuration information.
[0015] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0016] At least one processor; and
[0017] A memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the database communication method according to any embodiment of the present invention.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the database communication method described in any embodiment of the present invention.
[0020] The technical solution of this invention determines the setting keywords in the processing statements based on a syntax tree, and determines the processing strategy corresponding to the setting keywords in the target configuration file; when the processing strategy includes a database modification strategy, the configuration information of the database corresponding to the target component is modified according to the processing strategy. This achieves dynamic modification of the configuration information of the database corresponding to the target component during component communication, solving the problem of database communication barriers caused by non-processing statement expressions, and improving user programming efficiency and accuracy.
[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart of a database communication method provided according to an embodiment of the present invention;
[0024] Figure 2 This is a structural block diagram of the database communication method according to an embodiment of the present invention;
[0025] Figure 3 This is a structural block diagram of a database communication method provided according to another embodiment of the present invention;
[0026] Figure 4 This is a structural block diagram of a database communication method provided according to another embodiment of the present invention;
[0027] Figure 5 This is a structural block diagram of a database communication method provided according to another embodiment of the present invention;
[0028] Figure 6 A structural block diagram of a database communication device provided in an embodiment of the present invention;
[0029] Figure 7 A structural block diagram of a database communication device provided in another embodiment of the present invention;
[0030] Figure 8 This is a schematic diagram of the structure of an electronic device that implements the database communication method of this invention. Detailed Implementation
[0031] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "target," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0033] The technical terms involved in the embodiments of this invention include:
[0034] ORM: Object Relational Mapping, which solves the problem of how to map tables in a database to object entities in an application.
[0035] MyBatis: An open-source ORM framework that allows users to manipulate the database either by writing SQL manually or by calling interfaces generated by the framework.
[0036] JPA: An open-source ORM framework.
[0037] A syntax tree (AST) is an abstract representation of the syntactic structure of source code. It represents the syntactic structure of a programming language in a tree-like structure, where each node in the tree represents a structure within the source code.
[0038] The Visitor pattern is a programming design pattern that represents an operation that is applied to the elements of a given object structure. It allows users to define new operations that apply to these elements without changing their classes.
[0039] Figure 1This is a flowchart of a database communication method provided in an embodiment of the present invention. This embodiment is applicable to situations where database communication obstacles caused by non-SQL statement syntax problems are resolved by dynamically adjusting the corresponding configuration information in the database. This method can be executed by a database communication device, which can be implemented in hardware and / or software. The database communication device can be configured in the processor of an electronic device; specifically, the device can be optionally loaded into the electronic device as a plug-in. Figure 1 As shown, the method includes:
[0040] S110. Intercept the processing statement to be received by the target component. The processing statement is output by the output component.
[0041] The target component is the component that receives and executes the processing statements to be processed.
[0042] Output component 12 is the component that outputs processing statements to target component 11. One target component 11 is configured to correspond to one or more output components 12, see [link to documentation]. Figure 2 As shown.
[0043] The databases corresponding to the target component 11 and the output component 12 are any database 13 based on SQL statement communication, such as MyBatis, JPA, HardCode, etc.
[0044] In one embodiment, the interceptor is based on Spring's SpringFactoriesLoader (a factory loading mechanism, similar to Java SPI, which automatically loads components by scanning pre-defined configuration information at startup). It is seamlessly loaded into the user's application when the target component starts, and then intercepts the SQL statements to be received by the target component, i.e., the processing statements. In this embodiment, the processing statements include session information (i.e., a long-lived connection maintaining the relationship between the application and the database). The interceptor can be a StatementHandlerInterceptor based on the MyBatis Interceptor interface, or a StatementInterceptor in JPA; both rely on Spring's AOP mechanism to capture SQL statements and session information.
[0045] In one embodiment, AOP (Aspect-Oriented Programming, which specifies an aspect in the program, allowing for custom execution of program content before and after this aspect) or user-initiated calls are used as entry points to intercept processing statements received by the target component.
[0046] S120. Determine the setting keyword in the processing statement and determine the processing strategy corresponding to the setting keyword in the target configuration file. The target configuration file includes the setting keyword and the processing strategy corresponding to the setting keyword.
[0047] The setting keywords in the target configuration file vary depending on the associated database. For example, for the same processing statement, if the target component corresponds to database A, the processing statement can be executed directly. However, if the target component corresponds to database B, the processing statement cannot be executed directly and the parameter M in the database B configuration information needs to be modified. Therefore, if the target component corresponds to database A, the processing statement does not have a setting keyword, but if the target component corresponds to database B, it does include a setting keyword, and this setting keyword causes the target component to execute the processing statement based on parameter M.
[0048] In one embodiment, each field in the processing statement is compared with the keywords in the target configuration file. If they match, the corresponding field is used as the set keyword.
[0049] The processing strategies include, but are not limited to, database modification strategies, which are used to modify the corresponding configuration information of the database on which the target component executes processing statements.
[0050] In one embodiment, the target component communicates with only one output component, therefore the intercepted processing statement corresponds to a unique target configuration file. After determining the setting keyword in the processing statement, the processing strategy corresponding to that setting keyword is determined in the target configuration file.
[0051] In one embodiment, the target component communicates with at least two output components. Therefore, upon intercepting a processing statement, the target component determines the corresponding configuration file based on the identifier of the source database corresponding to the processing statement, and the pre-established correspondence between database identifiers and configuration file identifiers. This configuration file is then used as the target configuration file. The processing strategy corresponding to the set keywords is determined within the target configuration file. This improves the accuracy of determining the processing strategy corresponding to the processing statement.
[0052] For example, the target component corresponds to the DM database. In the target configuration file, the processing strategy for the setting keyword used for the field auto-increment function is: change IDENTITY_INSERT from the default disabled state to the enabled state; the processing strategy for the setting keyword used to indicate deduplication or comparison of EXT / BLOB fields is: change the ENABLE_BLOB_CMP_FLAG parameter from the default state to the enabled state; the processing strategy for the setting keyword used to indicate selection of non-group fields is: change the GROUP_OPT_FLAG parameter from the default state to the enabled state.
[0053] S130. If the processing strategy includes a database modification strategy, modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy.
[0054] Once the processing strategy is determined, if the processing strategy includes a database modification strategy, then the corresponding configuration information in the database corresponding to the target component is modified according to the database modification strategy. For example, if the database modification strategy is to change IDENTITY_INSERT from the default disabled state to the enabled state, then the IDENTITY_INSERT parameter in the database corresponding to the target component is changed from the default disabled state to the enabled state.
[0055] S140. Release the processing statement so that the processing statement is sent to the target component and executed by the target component based on the modified configuration information.
[0056] After modifying the corresponding configuration information in the database corresponding to the target component, the processing statement is released so that it can be sent to the target component. After receiving the processing statement, the target component executes the processing statement based on the modified configuration information.
[0057] Once the processing statement has been executed by the target component, the corresponding configuration information in the database corresponding to the target component is restored, that is, the state of the corresponding configuration information is restored to the default state. In this way, when using the configuration information later, there is no need to check its state; it can be used directly or its state can be modified directly.
[0058] The database communication method provided in this invention automatically intercepts processing statements to be received by a target component, determines the corresponding processing strategy in the configuration file, automatically modifies the database configuration information to be modified based on which the target component executes the processing statement, and automatically releases the processing statement after the corresponding configuration information is modified, so that the processing statement is sent to the target component and executed by the target component based on the modified configuration information. This achieves real-time dynamic modification of the database configuration information to be modified based on which the target component executes the processing statement. Thus, when the database on which the target component is based changes, only the corresponding configuration information in the target configuration file needs to be modified, without modifying the communication program between the output component and the target component. This significantly reduces the workload of R&D personnel and improves their work efficiency.
[0059] Figure 3 This is a flowchart of a database communication method provided in an embodiment of the present invention. This embodiment adds, based on the previous embodiments, "when the processing strategy includes a cache adjustment strategy, adjusting the cache capacity for data generated during the execution of processing statements according to the cache adjustment strategy." Figure 3 As shown, the method includes:
[0060] S210. Intercept the processing statement to be received by the target component. The processing statement is output by the output component.
[0061] S220. Determine the setting keyword in the processing statement and determine the processing strategy corresponding to the setting keyword in the target configuration file. The target configuration file includes the setting keyword and the processing strategy corresponding to the setting keyword.
[0062] S2301. If the processing strategy includes a database modification strategy, modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy.
[0063] S2302. When the processing strategy includes a cache adjustment strategy, modify the cache configuration information according to the cache adjustment strategy to adjust the cache capacity available for data generated during the execution of the processing statement.
[0064] Different processing statements require different cache capacity during execution. To ensure that processing statements are executed quickly, it is preferable to configure the cache capacity available for the execution of processing statements before the target component executes the processing statements.
[0065] If the processing strategy includes a cache adjustment strategy, it means that the processing statement will consume a lot of cache capacity during execution. Therefore, the cache capacity available for the data generated during the execution of the processing statement is adjusted according to the cache adjustment strategy so that the target component can quickly complete the processing statement.
[0066] For example, the first setting keyword corresponds to a first cache adjustment strategy, which is to modify the default cache size to 100MB; the second setting keyword corresponds to a second cache adjustment strategy, which is to modify the default cache size to 150MB. When the processor detects that a processing statement includes the first setting keyword, it modifies the cache size from the default value to 100MB according to the first cache adjustment strategy; when the processor detects that a processing statement includes the second setting keyword, it adjusts the cache size to 150MB according to the second cache adjustment strategy.
[0067] S240. Release the processing statement so that the processing statement is sent to the target component and executed by the target component based on the modified configuration information.
[0068] After detecting that the processing statement has been executed by the target component, the cache capacity is restored to the default value. This enables real-time dynamic modification of cached data without affecting the execution of subsequent processing statements that do not require cache capacity modification, thus achieving the goal of improving the execution efficiency of processing statements by temporarily changing the cache allocation.
[0069] In this embodiment, the cache modification strategy improves the processing speed of statements that consume a lot of cache capacity during execution, which helps to improve the running speed of the target component and the user's programming experience.
[0070] Figure 4 This is a flowchart of a database communication method provided in an embodiment of the present invention. This embodiment refines the method for determining the set keywords based on the foregoing embodiments. For example... Figure 4 As shown, the method includes:
[0071] S310. Intercept the processing statement to be received by the target component. The processing statement is output by the output component.
[0072] S3201. Determine the syntax tree corresponding to the processing statement; determine the setting keywords in the processing statement based on the syntax tree.
[0073] The concept of a syntax tree is similar to representing the structure of a statement. For example, a SELECT statement consists of a SELECT list, a WHERE clause, sorting fields, grouping fields, etc. The SELECT list consists of one or more SELECT items, and the WHERE clause includes at least one WHERE condition. This structure is a logical result of a general-to-specific structure, which is well represented by a tree.
[0074] The syntax tree consists of a root node and leaf nodes. Each node includes parsed content identification information and node type information, etc.
[0075] In one embodiment, existing syntax tree building methods are used to parse the processing statement to generate a syntax tree. Examples include durid (the SQL parsing engine) and corresponding components in Calcite.
[0076] After the syntax tree is generated, it is traversed using the visitor pattern, starting from the root node and proceeding to the last leaf node. Each node is checked to see if it contains a keyword from the target configuration file. If so, that keyword is used as the setting keyword.
[0077] For example, the statement `INSERT INTO TEST_TABLE(ID,`PARTITION`)VALUES(1,'TOM')` is an SQL statement with auto-increment functionality. This SQL statement is parsed to generate a syntax tree. Traversing all nodes of the syntax tree from top to bottom, it is found that the "INSERT" keyword in the SQL statement is a keyword in the target configuration file, and this keyword is used as the setting keyword.
[0078] S3202. Determine the processing strategy corresponding to the set keyword in the target configuration file. The target configuration file includes the set keyword and the processing strategy corresponding to the set keyword.
[0079] In the target configuration file, the processing strategy corresponding to "INSERT" is to change the status parameter of the table it points to from the default closed state to the enabled state.
[0080] S330. If the processing strategy includes a database modification strategy, modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy.
[0081] In one embodiment, when the processing strategy includes a database modification strategy, the target configuration parameters in the database required by the target component to execute the processing statement are determined according to the database modification strategy, and the default configuration data of the target configuration parameters is modified to the target configuration data.
[0082] Parse the tableSource attribute pointed to by "INSERT" in the previous steps. From the tableSource attribute, we can obtain the target table that this auto-increment statement attempts to insert into, which is "TEST_TABLE". Use "TEST_TABLE" as the table pointed to by "INSERT", that is, use TEST_TABLE as the target configuration parameter. According to the database modification policy (SETIDENTITY_INSERT TEST_TABLE ON) corresponding to "INSERT", change the target configuration parameter from the default disabled state to the enabled state.
[0083] S340. Release the processing statement so that the processing statement is sent to the target component and executed by the target component based on the modified configuration information.
[0084] If the IDENTITY column does not exist in the database driver output table when the target component executes the SQL statement in the aforementioned embodiment, it indicates that the target configuration information modification failed, i.e., the auto-increment function failed to be enabled; if the target component successfully executes the SQL statement in the aforementioned embodiment, it indicates that the auto-increment function of the database corresponding to the target component has been enabled during the execution of the SQL statement.
[0085] When the target component finishes executing the SQL statement, the status of TEST_TABLE in the database corresponding to the target component will be changed from enabled to the default disabled state.
[0086] This embodiment improves the speed and accuracy of determining the setting keywords in the processing statements by converting the processing statements into a syntax tree, thereby improving the speed and accuracy of determining database parameter strategies, the accuracy of modifying the corresponding configuration information in the database, and the speed and accuracy of database communication.
[0087] Figure 5 This is a flowchart of a database communication method provided in an embodiment of the present invention. Based on the foregoing embodiments, this embodiment refines the step of "modifying the corresponding configuration information in the database corresponding to the target component according to the database modification strategy when the processing strategy includes a database modification strategy." For example... Figure 5 As shown, the method includes:
[0088] S410: Intercept the processing statement to be received by the target component. The processing statement is output by the output component.
[0089] S4201. Determine the syntax tree corresponding to the processing statement; determine the setting keywords in the processing statement based on the syntax tree.
[0090] S4202. Determine the processing strategy corresponding to the set keyword in the target configuration file. The target configuration file includes the set keyword and the processing strategy corresponding to the set keyword.
[0091] S4301. When the processing strategy includes a database modification strategy and a translation strategy, modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy; modify the corresponding fields in the syntax tree according to the translation strategy to update the syntax tree, and generate the updated processing statement according to the updated syntax tree.
[0092] The processing strategy includes a database modification strategy and / or a translation strategy. When both a database modification strategy and a translation strategy are included, the database modification strategy modifies the corresponding configuration information in the database corresponding to the target component to resolve the issue of the target component being unable to execute processing statements due to database parameter configuration problems; the translation strategy modifies the syntax tree to resolve the issue of the target component being unable to execute processing statements due to syntax problems in the processing statements.
[0093] When processing strategies including database modification strategies and translation strategies, the number of set keywords is greater than or equal to 2, at least one of the at least two set keywords corresponds to the database modification strategy, and at least one of the at least two set keywords corresponds to the translation strategy.
[0094] For example, the target component corresponds to the DM database, and the processing statement is: INSERT INTO TEST_TABLE(ID,`PARTITION`)VALUES(1,'TOM'). The node representing SQLSelectItem in the syntax tree corresponding to this processing statement is identified. By obtaining its expr attribute, the column name currently being queried is obtained. The `PARTITION` field is found to contain backticks (``), which are keywords in the target configuration file. Therefore, this is used as a given keyword. The processing strategy corresponding to this keyword is determined in the target configuration file. This strategy is a translation strategy, specifically replacing backticks with quotation marks (`). Therefore, the backticks in `PARTITION` in the syntax tree are replaced with quotation marks to update the syntax tree. Then, the SQL statement corresponding to the updated syntax tree is determined, and this SQL statement is used as the updated processing statement. Based on the database modification strategy corresponding to INSERT in this processing statement determined in the aforementioned embodiment, the TEST_TABLE in the target component's database is changed from a default disabled state to an enabled state. This embodiment achieves the goal of seamlessly adapting the above processing statement to the DM database.
[0095] S4302. When the processing strategy includes a database modification strategy, a cache modification strategy, and a translation strategy, modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy, modify the cache configuration information according to the cache modification strategy, modify the corresponding fields in the syntax tree according to the translation strategy to update the syntax tree, and generate the updated processing statement according to the updated syntax tree.
[0096] When the processing strategy includes database modification strategy, cache modification strategy, and translation strategy, the corresponding configuration information in the corresponding library of the target component is modified according to the database modification strategy to solve the problem that the target component cannot execute processing statements due to database parameter configuration issues. The corresponding cache configuration information is modified according to the cache modification strategy to solve the problem that the target component cannot quickly execute processing statements due to cache capacity issues. The syntax tree is modified according to the translation strategy to solve the problem that the target component cannot execute processing statements due to syntax issues with the processing statements.
[0097] S440. Release the updated processing statement so that the updated processing statement is sent to the target component, and the target component executes the updated processing statement based on the modified configuration information.
[0098] In one embodiment, the updated processing statement is formatted, such as through format conversion or case conversion, to update the processing statement again. Finally, the updated processing statement is sent to the program's entry point, i.e., the interception point for the processing statement, and handed over by the ORM framework to the target component for execution.
[0099] In this embodiment of the invention, by combining different processing strategies, the problem that the target component cannot execute processing statements smoothly due to multiple issues is solved, so that the target component can execute processing statements smoothly, and the whole process is imperceptible to the target component.
[0100] Figure 6 This is a schematic diagram of the structure of a database communication device provided in an embodiment of the present invention. Figure 6 As shown, the device includes:
[0101] The acquisition module 610 is used to intercept the processing statement to be received by the target component, and the processing statement is output by the output component;
[0102] Keyword determination module 620 is used to determine the set keyword in the processing statement and to determine the processing strategy corresponding to the set keyword in the target configuration file. The target configuration file includes the set keyword and the processing strategy corresponding to the set keyword.
[0103] Information modification module 630 is used to modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy when the processing strategy includes a database modification strategy;
[0104] Release module 640 releases the processing statement so that the processing statement is sent to the target component and executed by the target component based on the modified configuration information.
[0105] Optionally, the information modification module 630 is used to determine the target configuration parameters in the database required by the target component when executing the processing statement according to the database modification strategy, and modify the default configuration data of the target configuration parameters to the target configuration data.
[0106] Optionally, the information modification module 630 is further configured to adjust the cache capacity available for data generated during the execution of the processing statement according to the cache adjustment strategy when the processing strategy includes a cache adjustment strategy.
[0107] Optionally, the keyword determination module 620 is used to determine the syntax tree corresponding to the processing statement; and to determine the set keywords in the processing statement based on the syntax tree.
[0108] Optionally, the keyword determination module 620 is used to determine the identifier of the source database corresponding to the processing statement; determine the target configuration file corresponding to the processing statement based on the identifier of the source database and the pre-established correspondence between database identifiers and configuration file identifiers; and determine the processing strategy corresponding to the set keyword in the target configuration file.
[0109] Optionally, the release module 640 is configured to, if the processing strategy further includes a translation strategy, modify the corresponding field in the syntax tree according to the translation strategy to update the syntax tree, generate an updated processing statement according to the updated syntax tree, and release the updated processing statement.
[0110] Optionally, such as Figure 7 As shown, the device also includes a recovery module 650, which is used to restore the corresponding configuration information in the database corresponding to the target component when the processing statement is executed by the target component.
[0111] The database communication method provided in this invention automatically intercepts processing statements to be received by a target component, determines the corresponding processing strategy in the configuration file, automatically modifies the database configuration information to be modified based on which the target component executes the processing statement, and automatically releases the processing statement after the corresponding configuration information is modified, so that the processing statement is sent to the target component and executed by the target component based on the modified configuration information. This achieves real-time dynamic modification of the database configuration information to be modified based on which the target component executes the processing statement. Thus, when the database on which the target component is based changes, only the corresponding configuration information in the target configuration file needs to be modified, without modifying the communication program between the output component and the target component. This significantly reduces the workload of R&D personnel and improves their work efficiency.
[0112] The database communication device provided in the embodiments of the present invention can execute the database communication method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0113] Figure 8 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0114] like Figure 8 As shown, the electronic device 80 includes at least one processor 81 and a memory, such as a read-only memory (ROM) 82 and a random access memory (RAM) 83, communicatively connected to the at least one processor 81. The memory stores computer programs executable by the at least one processor. The processor 81 can perform various appropriate actions and processes based on the computer program stored in the ROM 82 or loaded from storage unit 88 into the RAM 83. The RAM 83 can also store various programs and data required for the operation of the electronic device 80. The processor 81, ROM 82, and RAM 83 are interconnected via a bus 84. An input / output (I / O) interface 85 is also connected to the bus 84.
[0115] Multiple components in electronic device 80 are connected to I / O interface 85, including: input unit 86, such as keyboard, mouse, etc.; output unit 87, such as various types of monitors, speakers, etc.; storage unit 88, such as disk, optical disk, etc.; and communication unit 89, such as network card, modem, wireless transceiver, etc. Communication unit 89 allows electronic device 80 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0116] Processor 81 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 81 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 81 performs the various methods and processes described above, such as database communication methods.
[0117] In some embodiments, the database communication method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 88. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 80 via ROM 82 and / or communication unit 89. When the computer program is loaded into RAM 83 and executed by processor 81, one or more steps of the database communication method described above may be performed. Alternatively, in other embodiments, processor 81 may be configured to perform the database communication method by any other suitable means (e.g., by means of firmware).
[0118] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0119] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0120] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0121] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0122] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0123] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0124] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0125] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A database communication method, characterized in that, include: Intercept the processing statement to be received by the target component, the processing statement being output by the output component; The setting keyword in the processing statement is determined, and the processing strategy corresponding to the setting keyword is determined in the target configuration file, wherein the target configuration file includes the setting keyword and the processing strategy corresponding to the setting keyword; When the processing strategy includes a database modification strategy, the corresponding configuration information in the database corresponding to the target component is modified according to the database modification strategy; Release the processing statement so that it is sent to the target component, and the target component executes the processing statement based on the modified configuration information. If the processing statement is executed by the target component, restore the corresponding configuration information in the database of the target component.
2. The method according to claim 1, characterized in that, The step of modifying the corresponding configuration information in the database corresponding to the target component according to the database modification strategy includes: Based on the database modification strategy, the target configuration parameters in the database required by the target component to execute the processing statement are determined, and the default configuration data of the target configuration parameters is modified to the target configuration data.
3. The method according to claim 1, characterized in that, Before releasing the processing statement, the method further includes: If the processing strategy includes a cache adjustment strategy, the cache configuration information is modified according to the cache adjustment strategy to adjust the cache capacity available for data generated during the execution of the processing statement.
4. The method according to claim 1, characterized in that, The determination of the set keyword in the processing statement includes: Determine the syntax tree corresponding to the processing statement; The set keywords in the processing statement are determined based on the syntax tree.
5. The method according to claim 1, characterized in that, The step of determining the processing strategy corresponding to the set keyword in the target configuration file includes: Determine the identifier of the source database corresponding to the processing statement; Based on the identifier of the source database and the pre-established correspondence between database identifiers and configuration file identifiers, the target configuration file corresponding to the processing statement is determined; The processing strategy corresponding to the set keyword is determined in the target configuration file.
6. The method according to claim 4, characterized in that, The release of the processing statement includes: If the processing strategy also includes a translation strategy, the corresponding fields in the syntax tree are modified according to the translation strategy to update the syntax tree, and an updated processing statement is generated based on the updated syntax tree. Release the updated processing statements.
7. A database communication device, characterized in that, include: The acquisition module is used to intercept the processing statement to be received by the target component, and the processing statement is output by the output component; The keyword determination module is used to determine the set keyword in the processing statement and to determine the processing strategy corresponding to the set keyword in the target configuration file. The target configuration file includes the set keyword and the processing strategy corresponding to the set keyword. The information modification module is used to modify the corresponding configuration information in the database corresponding to the target component according to the database modification strategy when the processing strategy includes a database modification strategy; The release module releases the processing statement so that the processing statement is sent to the target component, and the target component executes the processing statement based on the modified configuration information. In addition, when the processing statement is executed by the target component, the corresponding configuration information in the database of the target component is restored.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the database communication method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the database communication method according to any one of claims 1-6.
Citation Information
Patent Citations
Data migration method and device for heterogeneous database, equipment and storage medium
CN115495440A