A domestic database automatic adaptation and function syntax conversion method and system

CN122838448APending Publication Date: 2026-09-29XIAMEN HYMAKE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610813918.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-08
Publication Date
2026-09-29

AI Technical Summary

Technical Problem

[0004]现有国产数据库适配转换存在以下问题:1)、手动修改Mapper XML逐个修改添加schema前缀,工作量大(可能涉及数百个文件)、易遗漏、难以回退;2)、数据库中间件引入额外组件、复杂度高;3)、ORM框架方言对国产数据库支持不完善,功能受限;4)、修改实体类注解@Table添加schema属性,工作量大且违反开闭原则

Benefits of technology

本发明公开一种国产数据库自动适配及函数语法转换方法及系统首先根据数据查询请求进行参数校验以及权限验证;如果参数校验以及权限验证都成功,则根据数据查询请求组装查询条件,并基于查询条件调用数据访问接口获取SQL语句。然后基于SQL语句和数据库驱动类参数进行自动适配处理,生成待执行语句。最后根据待执行语句从目标数据库中调取查询结果,并将查询结果进行封装以及格式化处理,发送至客户端或前端渲染展示。本发明在不对业务代码进行大量修改的情况下自动为SQL语句进行自动适配处理,对业务功能零侵入、零改造,实现MySQL数据库及国产数据库切换时的自动化无缝兼容适配,最小工作量下满足支持测试环境和生产环境的不同配置,支持不同客户生产环境数据库配置要求不一样问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122838448A_ABST
    Figure CN122838448A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of data conversion, in particular to a domestic database automatic adaptation and function syntax conversion method and system, first, according to the data query request, parameter verification and authority verification are carried out; if both are successful, the query condition is assembled according to the data query request, and the SQL statement is obtained based on the query condition and the data access interface is called. Then, based on the SQL statement and the database driver class parameters, automatic adaptation processing is carried out to generate a to-be-executed statement. Finally, according to the to-be-executed statement, the query result is retrieved from the target database, and the query result is encapsulated and formatted, and sent to the client or the front end for rendering and display. The present application automatically adapts the SQL statement without modifying the business code, and realizes zero-invasion and zero-reconstruction of the business function, automatic adaptation when switching between MySQL database and domestic database, and different configurations of support testing and production environment with minimum workload.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data conversion technology, and in particular to a method and system for automatic adaptation of domestic databases and function syntax conversion. Background Technology

[0002] With the increasing adoption of domestically developed databases, enterprises and institutions need to migrate their existing MySQL database systems to domestic databases (such as Kingbase, DM, Nanda General, and ShenTong). Besides database migration, the business systems themselves also need to be adapted for database compatibility. However, these domestic databases differ significantly from MySQL: 1. Differences in schema management: PostgreSQL-based domestic databases require table names to carry a schema prefix (such as xxx.table_name), while MySQL usually does not have this requirement.

[0003] Function syntax differences: MySQL-specific functions (such as YEAR(), DATE_FORMAT(), IFNULL(), etc.) require different syntax expressions in domestic databases.

[0004] The existing adaptation and conversion of domestic databases has the following problems: 1) Manually modifying the Mapper XML and adding the schema prefix one by one is labor-intensive (may involve hundreds of files), prone to omissions, and difficult to roll back; 2) Database middleware introduces additional components and has high complexity; 3) ORM framework dialects have incomplete support for domestic databases and limited functionality; 4) Modifying the entity class annotation @Table to add the schema attribute is labor-intensive and violates the open / closed principle.

[0005] Meanwhile, due to the diversity of customers, if we simply adapt to domestic databases, we need to maintain and update the business functions of two systems at the same time, which increases the workload and makes management and maintenance difficult.

[0006] In summary, developing a method suitable for domestic databases that can automatically add prefixes and perform function conversions has become an urgent problem to be solved in this field. Summary of the Invention

[0007] The purpose of this invention is to provide a method and system for automatic adaptation of domestic databases and conversion of function syntax, overcoming the problems existing in the background art.

[0008] To achieve the above objectives, this invention provides a method for automatic adaptation of domestic databases and function syntax conversion, the method comprising: Get the data query request sent by the user; Perform parameter validation and permission verification based on the data query request; determine whether the parameter validation and permission verification are successful; if they are successful, assemble query conditions based on the data query request, and call the data access interface to obtain the SQL statement based on the query conditions. Automatic adaptation processing is performed based on the SQL statement and database driver parameters to generate a statement to be executed. The query results are retrieved from the target database according to the statement to be executed, and the query results are encapsulated and formatted before being sent to the client or front-end for rendering and display.

[0009] Optionally, the automatic adaptation processing based on the SQL statement and database driver class parameters to generate the statement to be executed specifically includes: The SQL statement is intercepted using an interception component, and the database driver class parameters are obtained. Read the current data source driver class name based on the SQL statement and the database driver class parameters; Identify the type of the target database based on the current data source driver class name; Determine whether the target database is a MySQL database; if it is a MySQL database, the SQL statement is called the statement to be executed; if it is not a MySQL database, the SQL statement is automatically adapted, and the automatically adapted SQL statement is called the statement to be executed.

[0010] Optionally, identifying the target database type based on the current data source driver class name specifically includes: If the current data source driver class name contains "mysql", then the target database is MySQL; If the current data source driver class name contains "kingbase", then the target database is Kingbase. If the current data source driver class name contains "dm" or "dmdb", then the target database is DM Database; If the current data source driver class name contains "gaussdb", then the target database is Gauss Database.

[0011] Optionally, the automatic adaptation processing of the SQL statement specifically includes: The dialect functions in the SQL statement are converted based on the syntax mapping table from MySQL functions to the target domestic database; Regular expressions that match table names automatically add corresponding prefixes to the table names in the transformed SQL statements.

[0012] Optionally, the parameter validation is performed based on the basic data information in the data query request: if the number of parameters meets the requirements and all required fields exist, the parameter validation is successful.

[0013] Optionally, the permission verification is performed based on the user operation business in the data query request; if the current user does not have the operation permission corresponding to the user operation business, the permission verification fails; if the current user has the operation permission corresponding to the user operation business, the permission verification succeeds.

[0014] This invention also provides a domestic database automatic adaptation and function syntax conversion system, the system comprising: A client and a server; the client is connected to the server; the server includes a control layer, a business logic layer, an automatic adaptation layer, and a data processing layer; The client is used by users to send data query requests; the client is also used to render and display the encapsulated and formatted query results; The control layer receives a data query request from a user and performs parameter verification and permission verification based on the data query request; it then determines whether the parameter verification and permission verification are successful; if both are successful, it sends the data query request from the user to the business logic layer. The business logic layer is used to assemble query conditions according to the data query request, call the data access interface based on the query conditions to obtain the SQL statement, and send the SQL statement to the automatic adaptation layer. The automatic adaptation layer is used to perform automatic adaptation processing based on the SQL statement and database driver class parameters to generate a statement to be executed. The data processing layer is used to retrieve query results from the target database according to the statement to be executed, and to encapsulate and format the query results before sending them to the client and / or front end.

[0015] Optionally, the server further includes: The data acquisition layer is used to acquire data query requests sent by users and send them to the control layer.

[0016] The present invention also provides a computer-storable medium, characterized in that it stores a computer program, which, when executed by a processor, implements the steps of the above-described method for automatic adaptation of a domestic database and conversion of function syntax.

[0017] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, characterized in that: when the processor executes the computer program, it implements the steps of the above-described method for automatic adaptation of domestic databases and function syntax conversion.

[0018] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects: This invention discloses a method and system for automatic adaptation and function syntax conversion of domestic databases. First, it performs parameter validation and permission verification based on the data query request. If both validation and permission verification are successful, it assembles query conditions based on the data query request and calls a data access interface to obtain the SQL statement. Then, it performs automatic adaptation processing based on the SQL statement and database driver class parameters to generate an executable statement. Finally, it retrieves the query results from the target database based on the executable statement, encapsulates and formats the results, and sends them to the client or front-end for rendering and display. This invention automatically adapts SQL statements without extensive modification to business code, achieving zero intrusion and zero modification to business functions. It achieves automated and seamless compatibility adaptation when switching between MySQL and domestic databases, supporting different configurations in test and production environments with minimal workload, and addressing the issue of varying database configuration requirements in different customer production environments. Attached Figure Description

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

[0020] Figure 1 This is a flowchart illustrating the method for automatic adaptation of domestic databases and function syntax conversion in an embodiment of the present invention. Figure 2 This is a flowchart of the automatic adaptation process in an embodiment of the present invention. Detailed Implementation

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

[0022] The purpose of this invention is to provide a method and system for automatic adaptation of domestic databases and conversion of function syntax, overcoming the problems existing in the background art.

[0023] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0024] This invention discloses a domestic database automatic adaptation and function syntax conversion system, the system comprising: The client is used to send data query requests to users and to render and display the encapsulated and formatted query results.

[0025] The server consists of a data acquisition layer, a control layer, a business logic layer, an automatic adaptation layer, and a data processing layer. The specific functions of each layer are described below: The data acquisition layer is used to acquire data query requests sent by users and send them to the control layer. In this embodiment, users can send data query requests through client page operations, API calls, or other methods. The specific method for users to send corresponding data query requests can be selected according to actual needs. Data query requests include: the current user's operational business and basic data information; basic data information includes primary keys, user information, and business information, etc.

[0026] The control layer receives data query requests from users and performs parameter validation and permission verification based on these requests. It then determines whether both parameter and permission verifications are successful. If successful, the data query request is forwarded to the business logic layer. Specifically, parameter validation is performed based on the basic data information in the query request: if the number of parameters meets the requirements and all required fields are present, parameter validation is successful. Permission verification is performed based on the user's operational permissions in the query request: if the current user does not have the corresponding permissions, permission verification fails; otherwise, permission verification succeeds.

[0027] The business logic layer is used to assemble query conditions based on data query requests, call the data access interface to obtain SQL statements based on the query conditions, and send the SQL statements to the automatic adaptation layer; SQL stands for Structured Query Language.

[0028] The automatic adaptation layer is used to automatically adapt SQL statements and database driver class parameters to generate statements to be executed. Specifically, it includes: Intercept SQL statements using an interception component and obtain database driver class parameters; Read the current data source driver class name based on the SQL statement and database driver class parameters; Identify the type of the target database based on the current data source driver class name; The system determines whether the target database is a MySQL database. If it is a MySQL database, the SQL statement is designated as the statement to be executed. If it is not a MySQL database, the SQL statement undergoes automatic adaptation processing, and the adapted SQL statement is designated as the statement to be executed and sent to the data processing layer.

[0029] This invention identifies the target database type based on the current data source driver class name, specifically including: If the current data source driver class name contains "mysql", then the target database is MySQL, and the request is allowed directly.

[0030] If the current data source driver class name contains "kingbase", then the target database is Kingbase.

[0031] If the current data source driver class name contains "dm" or "dmdb", then the target database is DM Database.

[0032] If the current data source driver class name contains "gaussdb", then the target database is GaussDB;... Automatic adaptation for non-MySQL databases.

[0033] Automatic adaptation processing of SQL statements, specifically including: The dialect functions in SQL statements are converted based on a syntax mapping table from MySQL functions to the target domestic database. The conversion process is handled uniformly at the JDBC layer, requiring no modification to the upper-level business logic layer. The syntax mapping table from MySQL functions to the target domestic database is shown in Table 1.

[0034] 1 YEAR(col) EXTRACT(YEAR FROM col) \byear\s*\([^)]+\) 2 DATE_FORMAT(col,'%Y-%m-%d') TO_CHAR(col,'YYYY-MM-DD') DATE_FORMAT\s*\([^,]+,\s*'[^']+'\) 3 IFNULL(x, y) COALESCE(x, y) \bifnull\s*\([^,]+,\s*[^)]+\) 4 IF(cond, a, b) CASE WHEN cond THEN a ELSE b END \bif\s*\([^,]+,[^,]+,[^)]+\) 5 DATEDIFF(a, b) (a::date - b::date) \bdatediff\s*\([^,]+,\s*[^)]+\) 6 NOW() CURRENT_TIMESTAMP \bnow\s*\(\) 7 LOCATE(sub, str) STRPOS(str, sub) \blocates?\s*\([^,]+,\s*[^)]+\) 8 FIND_IN_SET(str, list) str = ANY(string_to_array(list,',')) \bfind_in_set\s*\([^,]+,\s*[^)]+\) 9 GROUP_CONCAT(col) STRING_AGG(col,',') \bgroup_concat\s*\([^)]+\) 10 DATE(col) col::date \bdate\s*\(([^)]+)\) Regular expressions matching table names automatically add corresponding prefixes (e.g., XXX.table) to table names in the transformed SQL statement; the SQL statement with the prefix added is then called the statement to be executed. The purpose of automatically adding corresponding prefixes to table names is to enable access to PostgreSQL-based databases. Prefix injection enables access to domestic databases without requiring modification to the upper-level business logic.

[0035] Regular expression for matching table names: (?i)(FROM|JOIN|INTO|UPDATE)\\s+([a-zA-Z_][a-zA-Z0-9_]*)(?=\\s|$|\\(|,|ON|WHERE|AND|OR) The table names in the converted SQL statement will automatically have the corresponding XXX prefix added: • FROM table → FROM XXX.table • JOIN table → JOIN XXX.table • INTO table → INTO XXX.table • UPDATE table → UPDATE XXX.table ... This invention first performs function transformation and then adds a prefix, executing them sequentially without interference. The transformed SQL is then passed to the target database driver for execution, yielding the result set.

[0036] The data processing layer is used to retrieve query results from the target database based on the statement to be executed, encapsulate and format the query results, and send them to the client or front-end for rendering and display. An example table of the transformation is shown in Table 2.

[0037] Year Extraction SELECT YEAR(create_time) FROM sys_user SELECT EXTRACT(YEAR FROM create_time) FROM XXX.sys_user Date Formatting SELECT DATE_FORMAT(create_time,'%Y-%m-%d') FROM project_info SELECT TO_CHAR(create_time,'YYYY-MM-DD') FROM XXX.project_info Null Value Handling SELECT IFNULL(user_name,'unknown') FROM sys_user SELECT COALESCE(user_name,'unknown') FROM XXX.sys_user Conditional Judgment SELECT IF(status=1,'enabled','disabled') FROM sys_user SELECT CASE WHEN status=1 THEN 'Enable' ELSE 'Disable' END FROM XXX.sys_user Set contains SELECT * FROM menu WHERE FIND_IN_SET(menu_id,'1,2,3') SELECT * FROM XXX.menu WHERE menu_id = ANY(string_to_array('1,2,3',',')) like Figures 1-2 As shown, this invention also discloses a method for automatic adaptation of domestic databases and function syntax conversion, including: Step S1: Obtain the data query request sent by the user.

[0038] Step S2: Perform parameter validation and permission verification based on the data query request; determine whether the parameter validation and permission verification are successful; if they are successful, assemble the query conditions based on the data query request, and call the data access interface to obtain the SQL statement based on the query conditions.

[0039] Step S3: Perform automatic adaptation processing based on SQL statements and database driver class parameters to generate statements to be executed.

[0040] Step S4: Retrieve the query results from the target database based on the statement to be executed, encapsulate and format the query results, and send them to the client or front-end for rendering and display.

[0041] The following is a detailed discussion of each step: Step S3: Perform automatic adaptation processing based on the SQL statement and database driver class parameters to generate the statement to be executed, specifically including: Step S31: Use the interception component to intercept SQL statements and obtain database driver class parameters.

[0042] Step S32: Read the current data source driver class name based on the SQL statement and database driver class parameters.

[0043] Step S33: Identify the type of the target database based on the current data source driver class name, specifically including: If the current data source driver class name contains "mysql", then the target database is MySQL.

[0044] If the current data source driver class name contains "kingbase", then the target database is Kingbase.

[0045] If the current data source driver class name contains "dm" or "dmdb", then the target database is DM Database.

[0046] If the current data source driver class name contains "gaussdb", then the target database is Gauss Database.

[0047] Step S34: Determine if the target database is a MySQL database. If it is a MySQL database, the SQL statement is designated as the statement to be executed. If it is not a MySQL database, the SQL statement is automatically adapted, and the adapted SQL statement is designated as the statement to be executed.

[0048] The SQL statement is automatically adapted, specifically including: This method uses a syntax mapping table from MySQL functions to target domestic databases to convert dialect functions in SQL statements.

[0049] Regular expressions that match table names automatically add corresponding prefixes to the table names in the transformed SQL statements.

[0050] This invention automatically adds prefixes to table names in SQL statements without modifying business code, and automatically converts MySQL-specific function syntax into syntax compatible with the target domestic database. It achieves zero intrusion and zero modification to business functions without extensive changes to existing business code, realizes automated and seamless compatibility adaptation when switching between MySQL and domestic databases, and meets different configurations for testing and production environments with minimal workload, addressing the issue of different database configuration requirements for different customers' production environments.

[0051] Spring Boot, based on Spring 4.0, not only inherits the excellent features of the original Spring framework but also further simplifies the entire process of building and developing Spring applications by simplifying configuration. Spring Boot is responsible for quickly building projects, managing configurations, and integrating components; the ORM framework is responsible for automatically mapping Java objects to database tables, simplifying database operations.

[0052] Mainstream ORM frameworks on the market include MyBatis, Hibernate / JPA, and Spring Data JDBC. 1) MyBatis is a Java-based persistence layer framework, formerly known as iBatis. It supports configuring SQL mappings via XML or annotations, reducing manual JDBC coding. 2) JPA (Java Persistence API) is the standard API specification for Object Relational Mapping (ORM) in the Java EE platform. It is not a concrete implementation itself, but only defines interfaces and rules. JPA is the Java persistence specification standard, and Hibernate is an ORM framework that implements this specification. The two have an "interface and implementation" relationship.

[0053] 3) Hibernate is an open-source object-relational mapping framework that provides a lightweight object wrapper around JDBC and is one of the most popular implementations of the JPA specification.

[0054] 4) Spring Data JDBC is a lightweight persistence layer framework in the Spring Data family used to simplify access to relational databases. It is based on JDBC and emphasizes aggregate root-driven persistence, no lazy loading, no first-level cache, and no dirty checking. It is suitable for simple, high-performance scenarios with explicit and controllable SQL.

[0055] Java Database Connectivity (JDBC) is an application programming interface in the Java language that specifies how client programs access databases, providing methods such as querying and updating data in the database.

[0056] ORM (Object-Relational Mapping): Object-relational mapping.

[0057] In this project, the chosen ORM frameworks differ, and their specific implementation details also differ, as detailed below: I. MyBatis Implementation Solution The project has already configured a data source. The automatic configuration classes for JPA and the data source are excluded in the Spring Boot startup class. After project startup, the MyBatis SqlSessionFactory is automatically initialized. The system creates a SqlSessionFactoryBean, and the SQL interception component is registered to the SqlSessionFactory using the Configuration.addInterceptor method. By implementing the MyBatis Interceptor interface, SQL statements are intercepted before the StatementHandler.prepare() method is executed. After interception, function syntax transformation and schema prefix addition are performed. At this point, the SQL text is complete and easily modifiable. All SQL executed through MyBatis will be intercepted and processed, including Mapper interface calls and XML SQL. The core steps are as follows: 1) Intercept the component startup and intercept the StatementHandler.prepare() method. At this point, the SQL has been assembled and the parameters have been bound.

[0058] 2) Receive SQL to be executed: Obtain the original SQL statement in BoundSql through MetaObject reflection, and configure the database driver class parameters at the same time.

[0059] 3) Database type identification: Read the current data source configuration and determine whether it is a domestic database based on the current data source driver class name (MySQL is allowed directly). If so, perform automatic adaptation processing.

[0060] 4) Automatic adaptation processing: a. Function syntax conversion: Use regular expressions to convert MySQL functions into target database-compatible syntax, ensuring that they execute without problems under the target database.

[0061] b. Add a schema prefix: Add a schema prefix to the table names in the FROM, JOIN, INTO, and UPDATE clauses to ensure that there are no problems when executing the code on the target database.

[0062] 5) Execute the converted SQL: Return the converted SQL to the upper layer for execution, output the SQL conversion log, record the original SQL statement and the converted SQL statement, which is convenient for troubleshooting and system debugging.

[0063] 6) Execute the transformed SQL statement.

[0064] II. Hibernate / JPA Implementation Solution: After configuring Hibernate / Spring Data JPA in the project, the EntityManagerFactory automatically initializes upon project startup. The Interceptor takes effect during SQL generation, intercepting SQL before it is sent to the database. After interception, it performs function syntax transformation and adds schema prefixes. All SQL executed via JPA / Hibernate is processed. The core steps are as follows: 1) When the interceptor component starts, create an interceptor class that inherits from EmptyInterceptor and override the onPrepareStatement() method.

[0065] 2) Receive SQL to be executed: Intercept the prepared SQL through the onPrepareStatement method of the interceptor to obtain the original SQL.

[0066] 3) Database type identification: Automatically identify the database type using Dialect and determine whether it is a domestic database (MySQL is allowed directly). If so, perform automatic adaptation processing.

[0067] 4) Automatic adaptation processing: a. Function syntax conversion: Use regular expressions to convert MySQL functions into target database-compatible syntax, ensuring that they execute without problems under the target database.

[0068] b. Add a schema prefix: Add a schema prefix to the table names in the FROM, JOIN, INTO, and UPDATE clauses to ensure that there are no problems when executing the code on the target database.

[0069] 5) Execute the converted SQL: Return the converted SQL to the upper layer for execution, output the SQL conversion log, record the original SQL statement and the converted SQL statement, which is convenient for troubleshooting and system debugging.

[0070] 6) Execute the transformed SQL statement.

[0071] III. JDBC Implementation Solution Configure RelationalDatabase and JdbcOperations in the project, intercept the data access method when it is executed, obtain the SQL statement and convert it. All CRUD operations executed through Spring Data JDBC Repository will be processed. The default strategy is wrapped using the decorator pattern to keep the behavior of other methods unchanged.

[0072] 1) Create a class that implements the DataAccessStrategy interface and holds a reference to the default strategy. Override key methods such as insert(), update(), delete(), findAll(), etc., to intercept the SQL execution flow.

[0073] 2) Receive SQL to be executed: In the overridden method, before calling the default strategy method, obtain the original SQL statement to be executed.

[0074] 3) Database type identification: Obtain database metadata through JdbcTemplate or DataSource, automatically identify the database type, and automatically identify the database type through Dialect to determine whether it is a domestic database (MySQL is allowed directly). If so, perform automatic adaptation processing.

[0075] 4) Automatic adaptation processing: a. Function syntax conversion: Use regular expressions to convert MySQL functions into target database-compatible syntax, ensuring that they execute without problems under the target database.

[0076] b. Add a schema prefix: Add a schema prefix to the table names in the FROM, JOIN, INTO, and UPDATE clauses to ensure that there are no problems when executing the code on the target database.

[0077] 5) Execute the converted SQL: Write the converted SQL back to the query object, output the SQL conversion log, record the original SQL statement and the converted SQL statement, which is convenient for troubleshooting and system debugging.

[0078] 6) Execute the transformed SQL statement.

[0079] The present invention also discloses a computer-storable medium storing a computer program, which, when executed by a processor, implements the steps of the above-described method for automatic adaptation of a domestic database and conversion of function syntax.

[0080] Embodiments of the present invention may be provided as methods, systems, or computer program products. The invention may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the invention may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0081] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0082] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0083] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0084] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method for automatic adaptation of domestic databases and function syntax conversion.

[0085] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0086] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for automatic adaptation and function syntax conversion of domestic databases, characterized in that, The method includes: Get the data query request sent by the user; Perform parameter validation and permission verification based on the data query request; determine whether the parameter validation and permission verification are successful; if they are successful, assemble query conditions based on the data query request, and call the data access interface to obtain the SQL statement based on the query conditions. Automatic adaptation processing is performed based on the SQL statement and database driver parameters to generate a statement to be executed. The query results are retrieved from the target database according to the statement to be executed, and the query results are encapsulated and formatted before being sent to the client or front-end for rendering and display.

2. The method for automatic adaptation of domestic databases and function syntax conversion according to claim 1, characterized in that, The automatic adaptation process based on the SQL statement and database driver parameters to generate the statement to be executed specifically includes: The SQL statement is intercepted using an interception component, and the database driver class parameters are obtained. Read the current data source driver class name based on the SQL statement and the database driver class parameters; Identify the type of the target database based on the current data source driver class name; Determine whether the target database is a MySQL database; if it is a MySQL database, the SQL statement is called the statement to be executed; if it is not a MySQL database, the SQL statement is automatically adapted, and the automatically adapted SQL statement is called the statement to be executed.

3. The method for automatic adaptation of domestic databases and function syntax conversion according to claim 2, characterized in that, The step of identifying the target database type based on the current data source driver class name specifically includes: If the current data source driver class name contains "mysql", then the target database is MySQL; If the current data source driver class name contains "kingbase", then the target database is Kingbase. If the current data source driver class name contains "dm" or "dmdb", then the target database is DM Database; If the current data source driver class name contains "gaussdb", then the target database is Gauss Database.

4. The method for automatic adaptation of domestic databases and function syntax conversion according to claim 2, characterized in that, The automatic adaptation processing of the SQL statement specifically includes: The dialect functions in the SQL statement are converted based on the syntax mapping table from MySQL functions to the target domestic database; Regular expressions that match table names automatically add corresponding prefixes to the table names in the transformed SQL statements.

5. The method for automatic adaptation of domestic databases and function syntax conversion according to claim 1, characterized in that, The parameter validation is performed based on the basic data information in the data query request: if the number of parameters meets the requirements and all required fields exist, the parameter validation is successful.

6. The method for automatic adaptation of domestic databases and function syntax conversion according to claim 5, characterized in that, The user operation request is used to verify permissions. If the current user does not have the corresponding operation permission, the permission verification fails. If the current user has the corresponding operation permission, the permission verification succeeds.

7. A domestic database automatic adaptation and function syntax conversion system, characterized in that, The system includes: A client and a server; the client is connected to the server; the server includes a control layer, a business logic layer, an automatic adaptation layer, and a data processing layer; The client is used by users to send data query requests; the client is also used to render and display the encapsulated and formatted query results; The control layer receives a data query request from a user and performs parameter verification and permission verification based on the data query request; it then determines whether the parameter verification and permission verification are successful; if both are successful, it sends the data query request from the user to the business logic layer. The business logic layer is used to assemble query conditions according to the data query request, call the data access interface based on the query conditions to obtain the SQL statement, and send the SQL statement to the automatic adaptation layer. The automatic adaptation layer is used to perform automatic adaptation processing based on the SQL statement and database driver class parameters to generate a statement to be executed. The data processing layer is used to retrieve query results from the target database according to the statement to be executed, and to encapsulate and format the query results before sending them to the client and / or front end.

8. The domestic database automatic adaptation and function syntax conversion system according to claim 7, characterized in that, The server also includes: The data acquisition layer is used to acquire data query requests sent by users and send them to the control layer.

9. A computer-storable medium, characterized in that, The system contains a computer program, which, when executed by a processor, implements the steps of a method for automatic adaptation of domestic databases and function syntax conversion as described in any one of claims 1-6.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the steps of the method for automatic adaptation of domestic databases and function syntax conversion as described in any one of claims 1-6.