A method, device and medium for implementing multi-database compatibility of an application program
By introducing the MyBatis framework into application development and configuring the database vendor identifier, the incompatibility problem of multiple databases is solved, and the compatibility and stability of multiple databases are achieved.
Patent Information
- Application Number
- CN202111456754.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2041-12-01
AI Technical Summary
When multiple databases exist in the same application, incompatibility issues may occur, affecting normal operation.
During the application development process, a specified framework structure, such as MyBatis, is introduced to configure database vendor identifiers corresponding to multiple databases. SQL statements are determined based on the database vendor identifiers and syntax information, and compatibility with multiple databases is achieved through database attribute identifiers.
It achieves compatibility with multiple databases, reduces the workload of developers, and improves the stability and flexibility of applications.
Smart Images

Figure CN114138815B_ABST
Abstract
Claims
1. A method for implementing multi-database compatibility of an application, characterized in that: The method comprises: In the development process of the application, a specified framework structure is introduced; In the specified framework structure, database vendor identifiers corresponding to multiple databases are configured; determining a plurality of SQL statements for the plurality of databases according to the database vendor identifier and syntax information corresponding to the plurality of databases; If the determined multiple SQL statements are incompatible among the multiple databases, database attribute identification is performed on the multiple SQL statements of the multiple databases according to the database vendor identification, so that the designated framework structure executes the SQL statements corresponding to the multiple databases respectively according to the database attribute identification, thereby achieving compatibility of the multiple databases; In the specified framework structure, the manufacturer identifiers corresponding to the various databases are configured, specifically including: If the multiple databases to be compatible include databases of the same type but different versions, determining the database identifiers of the multiple databases according to the version numbers of the multiple databases; At the interface of the database vendor identifier in the specified framework structure, defining the database identifiers of the plurality of databases according to preset rules; In the configuration file of the specified framework structure, database vendor identifiers corresponding to the multiple databases are configured, so that the database identifiers are effective in the specified framework structure through the configured database vendor identifiers, and database attribute identifiers are performed on the multiple SQL statements according to the multiple database identifiers; Determining multiple SQL statements for the multiple databases based on the database vendor identifier and syntax information corresponding to the multiple databases specifically includes: In the DAO layer of the specified framework structure, determining the database type according to the database identifiers corresponding to the multiple databases; Determine the SQL statement corresponding to the database based on the database syntax information corresponding to the database type; Before performing database attribute identification on the multiple SQL statements of the multiple databases according to the database vendor identifier, the method further includes: Determining whether the multiple SQL statements are compatible across the multiple databases based on types of the multiple SQL statements, wherein the type of each SQL statement includes a common statement and a non-common statement; If there is a non-universal statement among the multiple SQL statements, then the multiple SQL statements are incompatible among the multiple databases; If the multiple SQL statements are all common statements, then the multiple SQL statements are compatible in the multiple databases; If the determined multiple SQL statements are incompatible in the multiple databases, performing database attribute identification on the multiple SQL statements in the multiple databases according to the database vendor identifiers specifically includes: Using an if function, respectively adding the corresponding database identifiers to the multiple non-universal statements, performing database attribute identification on the multiple non-universal statements, and generating multiple identified non-universal statements; The identified SQL statements corresponding to the multiple databases are determined according to the common statements in the multiple SQL statements and the multiple identified non-common statements.
2. The method for implementing multi-database compatibility of an application according to claim 1, characterized in that: In the specified framework structure, the manufacturer identifiers corresponding to the various databases are configured, specifically including: If the multiple databases to be compatible are databases of different types, determining database vendor identifiers corresponding to the multiple databases according to the types of the multiple databases; In the configuration file of the specified framework structure, database vendor identifiers corresponding to the multiple databases are configured; The database identifiers corresponding to the multiple databases are introduced through the database vendor identifier, so as to perform database attribute identification on the multiple SQL statements according to the multiple database identifiers.
3. The method for implementing multi-database compatibility of an application according to claim 1, characterized in that: In the process of developing the application, before introducing the specified framework structure, the method further includes: Determine the data type of the database according to the data object of the database to be compatible; When the data object is a binary large object, the data type is a blob type; When the data object is a long text, the data type is text type; When the data object is of a numeric type, the data type is a decimal type; When the field length of the data object is determined, the data type is char type; When the field length of the data object is uncertain, the data type is varchar type.
4. The method for implementing multi-database compatibility of an application according to claim 1, characterized in that: The multiple databases are all domestic databases.
5. A device for implementing multi-database compatibility of an application, characterized in that: The device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 4.
6. A non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Security multi-compatibility lightweight database adaptive development and operation device supporting domestic database
CN111241065A