[go: up one dir, main page]

CN114138815B - A method, device and medium for implementing multi-database compatibility of an application program - Google Patents

A method, device and medium for implementing multi-database compatibility of an application program

Info

Publication number
CN114138815B
CN114138815B CN202111456754.4A CN202111456754A CN114138815B CN 114138815 B CN114138815 B CN 114138815B CN 202111456754 A CN202111456754 A CN 202111456754A CN 114138815 B CN114138815 B CN 114138815B
Authority
CN
China
Prior art keywords
database
databases
sentences
identifiers
sql
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111456754.4A
Other languages
Chinese (zh)
Other versions
CN114138815A (en
Inventor
牛文涛
曹雪韬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Inspur Genersoft Information Technology Co Ltd
Original Assignee
Shandong Inspur Genersoft Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Inspur Genersoft Information Technology Co Ltd filed Critical Shandong Inspur Genersoft Information Technology Co Ltd
Priority to CN202111456754.4A priority Critical patent/CN114138815B/en
Publication of CN114138815A publication Critical patent/CN114138815A/en
Application granted granted Critical
Publication of CN114138815B publication Critical patent/CN114138815B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the specification discloses a multi-database compatibility realization method, equipment and medium of an application program, wherein the method comprises the steps of introducing a designated framework structure in the development process of the application program, configuring database manufacturer identifiers corresponding to a plurality of databases in the designated framework structure, determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases according to the database manufacturer identifiers, and carrying out database attribute identification on the SQL sentences of the databases according to the database manufacturer identifiers if the SQL sentences are incompatible in the databases, so that the designated framework structure executes the SQL sentences corresponding to the databases according to the database attribute identifiers, and realizing the compatibility of the databases. When a plurality of databases are connected, corresponding SQL sentences can be executed to realize the compatibility of the multiple databases, and if the databases need to be modified, the database compatibility can be realized by configuring corresponding database manufacturer identifiers and adding database attributes to the corresponding SQL sentences.

Description

Multi-database compatibility implementation method, equipment and medium of application program
Technical Field
The present disclosure relates to the field of database technologies, and in particular, to a method, an apparatus, and a medium for implementing multi-database compatibility of an application program.
Background
An application refers to a computer program that operates in a user mode to interact with a user to perform a particular task or tasks, with a visual user interface. The database is used to store data in the application, and different databases may store different data.
In the prior art, the situation that a plurality of databases exist in the same application program exists generally, but different databases may be incompatible in the same application program, which may affect the normal operation of the application program.
Disclosure of Invention
One or more embodiments of the present disclosure provide a method, an apparatus, and a medium for implementing multi-database compatibility of an application program, which are used to solve the technical problem that a situation that multiple databases exist in the same application program is ubiquitous, but different databases may be incompatible in the same application program, which may affect normal operation of the application program.
One or more embodiments of the present disclosure adopt the following technical solutions:
One or more embodiments of the present disclosure provide a method for implementing multi-database compatibility of an application program, where the method includes introducing a specified framework structure in a development process of the application program, configuring database vendor identifiers corresponding to a plurality of databases in the specified framework structure, determining a plurality of SQL statements of the plurality of databases according to syntax information corresponding to the database vendor identifiers, and if the determined plurality of SQL statements are not compatible in the plurality of databases, performing database attribute identifiers on the plurality of SQL statements of the plurality of databases according to the database vendor identifiers, so that the specified framework structure executes the SQL statements corresponding to the plurality of databases respectively according to the database attribute identifiers, thereby implementing compatibility of the plurality of databases.
Further, the configuration of vendor identifiers corresponding to multiple databases in the specified frame structure specifically includes determining database vendor identifiers corresponding to the multiple databases according to the types of the multiple databases if the multiple databases to be compatible are different types of databases, configuring database vendor identifiers corresponding to the multiple databases in a configuration file of the specified frame structure, and introducing database identifiers corresponding to the multiple databases respectively through the database vendor identifiers so as to perform database attribute identifiers on the multiple SQL sentences according to the multiple database identifiers.
Further, configuring manufacturer identifiers corresponding to multiple databases in the specified frame structure specifically includes determining database identifiers of the multiple databases according to version numbers of the multiple databases if the multiple databases to be compatible include databases of the same type and different versions, defining the database identifiers of the multiple databases at interfaces of the database manufacturer identifiers in the specified frame structure according to preset rules, and configuring the database manufacturer identifiers corresponding to the multiple databases in a configuration file of the specified frame structure so as to enable the database identifiers to be effective in the specified frame structure through the configured database manufacturer identifiers, and performing database attribute identification on the multiple SQL sentences according to the multiple database identifiers.
Further, the method comprises the steps of determining SQL sentences of the databases according to the database grammar information corresponding to the databases through the database manufacturer identifiers, specifically comprising the steps of determining the database types according to the database identifiers corresponding to the databases in a DAO layer of a designated framework structure, and determining the SQL sentences corresponding to the databases according to the database grammar information corresponding to the database types.
Further, before the multiple databases are identified according to the database manufacturer identification, the method further comprises judging whether the multiple SQL sentences are compatible in the multiple databases according to the types of the multiple SQL sentences, wherein each type of the SQL sentences comprises a general sentence and a non-general sentence, if the non-general sentences exist in the multiple SQL sentences, the multiple SQL sentences are not compatible in the multiple databases, and if the multiple SQL sentences are all general sentences, the multiple SQL sentences are compatible in the multiple databases.
Further, if the determined SQL sentences are incompatible in the databases, performing database attribute identification on the SQL sentences of the databases according to the database manufacturer identifications, specifically comprising the steps of respectively adding corresponding database identifications in the non-general sentences by using an if function, performing database attribute identification on the non-general sentences to generate a plurality of identified non-general sentences, and determining the identified SQL sentences corresponding to the databases according to the general sentences in the SQL sentences and the non-general sentences after the identification.
Further, before the appointed framework structure is introduced in the development process of the application program, the method further comprises the steps of determining the data type of a database according to the data object of the database to be compatible, wherein 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 a text type, when the data object is a digital type, the data type is a explanatory type, when the field length of the data object is determined, the data type is a char type, and when the field length of the data object is uncertain, the data type is a varchar type.
Further, the databases are all domestic databases.
One or more embodiments of the present specification provide a multi-database compatible implementation device for an application program, the device comprising at least one processor, and
A memory communicatively coupled to the at least one processor, wherein,
The memory stores instructions executable by the at least one processor, the instructions are executable by the at least one processor to enable the at least one processor to:
The method comprises the steps of introducing a specified framework structure in the development process of an application program, configuring database manufacturer identifications corresponding to a plurality of databases in the specified framework structure, determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases of the database manufacturer identifications, and if the determined SQL sentences are incompatible in the databases, carrying out database attribute identification on the SQL sentences of the databases according to the database manufacturer identifications so as to facilitate the specified framework structure to execute the SQL sentences corresponding to the databases according to the database attribute identifications, thereby realizing compatibility of the databases.
One or more embodiments of the present specification provide a non-volatile computer storage medium storing computer-executable instructions configured to:
the method comprises the steps of introducing a specified framework structure in the development process of an application program, configuring database manufacturer identifications corresponding to a plurality of databases in the specified framework structure, determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases of the database manufacturer identifications, and if the determined SQL sentences are incompatible in the databases, carrying out database attribute identification on the SQL sentences of the databases according to the database manufacturer identifications so as to facilitate the specified framework structure to execute the SQL sentences respectively corresponding to the databases according to the database attribute identifications, thereby realizing compatibility of the databases.
The technical scheme adopted by the embodiment of the specification has the advantages that the appointed framework structure is introduced, the database manufacturer identification is configured in the framework structure, the database attribute identification is carried out on the SQL statement according to the database manufacturer identification, when a plurality of databases are connected, the corresponding SQL statement can be executed according to the connected databases, the compatibility of the databases is realized, when the service code is required to be modified, the database compatibility can be realized only by configuring the corresponding database manufacturer identification and adding the database attribute to the corresponding SQL statement.
Drawings
In order to more clearly illustrate the embodiments of the present description or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some of the embodiments described in the present description, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. In the drawings:
FIG. 1 is a flowchart of a method for implementing multi-database compatibility of an application according to an embodiment of the present disclosure;
FIG. 2 is a flowchart of another implementation method for implementing multi-database compatibility of an application according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a multi-database compatible implementation device of an application according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present disclosure.
With the development of information technology, application programs are becoming more and more popular. An application refers to a computer program that operates in a user mode to interact with a user to perform a particular task or tasks, with a visual user interface. The database is used to store data in the application, and different databases may store different data.
In the prior art, the situation that a plurality of databases exist in the same application program exists generally, but different databases may be incompatible in the same application program, which may affect the normal operation of the application program. Most Java application designs currently only consider supporting a specific database, which is typically selected from the large MySql database. In practical application, there may be a situation that the business needs to use other databases, if different databases are used, such as a domestic database for dream, shenzhou, etc. The grammar of different databases varies, and an application designed for a particular database cannot be compatible with other types of databases, resulting in incompatibility of the databases. When the database needs to be replaced, the developer needs to modify the service codes, so that the workload of the developer is increased, and the use of users is not facilitated.
The embodiment of the present disclosure provides a method for implementing multi-database compatibility of an application program, where an execution body may be a server or any processing device having a data processing function, and fig. 1 is a flow chart of a method for implementing multi-database compatibility of an application program, as shown in fig. 1, where the method includes the following steps:
Step S101, introducing a specified framework structure in the development process of the application program.
In order to solve the problem that the databases are incompatible when other databases are selected, the embodiment of the specification introduces a specified framework structure in the development process of the application program, and the specified framework structure is a framework capable of supporting multiple databases, for example MyBatis, myBatis is an excellent persistent layer framework which supports customized SQL, storage process and advanced mapping, myBatis avoids almost all JDBC codes and manually set parameters and acquired result sets, and simple XML or annotation can be used for configuring and mapping native information and mapping interface and Java POJOs (Plain Ordinary Java Object, common Java object) into records in the database. In addition, myBatis may execute different sentences according to different database manufacturers, and the MyBatis framework is selected for explanation in the embodiment of the present specification.
In one embodiment of the present disclosure, the plurality of databases may be of a type that is a domestic database, such as a dream database, a state general database, etc., or a MySql database.
Since in practical applications there are multiple types of data objects, it is necessary to determine the data type of the corresponding database from the data object. In programming, multiple database compatibility mainly involves table structure and data types. Such as MySQL, dream and Shenzhou compatible general databases, using blob types for binary large objects, text types for long text data objects, decimal types for digital type data objects, float types and double types avoided, char types for data objects of certain determinable length fields, otherwise varchar types.
Step S102, configuring database manufacturer identifiers corresponding to a plurality of databases in a specified framework structure.
MyBatis can execute different statements according to different database vendors, and the support of multiple vendors is based on the database identification attribute, also called databaseId attribute, in the mapped statement. MyBatis will load statements with matching current database databaseId attributes and all without databaseId attributes. If the same statement with databaseId and without databaseId are found at the same time, the latter is discarded.
In one embodiment of the present disclosure, after a specified framework is selected, database information needs to be configured in the framework according to the characteristics of the framework to achieve multi-database compatibility of the application.
The existing databases can be of the same type except different types of databases, but belong to databases of different versions, and grammar information of the databases also has differences. That is, the multiple databases of the application program are compatible, and may be different types of databases, such as a dream database and a Shenzhou general database, or different versions of the same type of databases, such as multiple versions of the dream database.
In one embodiment of the present disclosure, if a plurality of databases to be compatible are different types of databases, determining database manufacturer identifiers corresponding to the plurality of databases according to the types of the plurality of databases, configuring database manufacturer identifiers corresponding to the plurality of databases in a configuration file of a specified framework structure, and introducing database identifiers corresponding to the plurality of databases respectively through the database manufacturer identifiers so as to perform database attribute identifiers on the plurality of SQL sentences according to the plurality of database identifiers.
That is, the database vendor identification, which may also be referred to as databaseIdProvider, is added to the mybati configuration file mybs-config. An example code is that the db_vector implementation corresponding to < databaseIdProvider type = "db_vector"/>, databaseIdProvider will set databaseId to the string returned by DatabaseMetaData # getDatabaseProductName (). Since these strings are typically very long and different versions of the same product return different values, they can be made shorter by setting the attribute alias. The database product names provided by each database vendor are declared in the database driver, such as MySQL, dream, and general database vendor of the Shenzhou are MySQL, DM DBMS, and OSCAR, respectively, and then the following can be configured:
<databaseIdProvider type="DB_VENDOR">
<property name="MySQL"value="mysql"/>
<property name="DM DBMS"value="dm"/>
<property name="OSCAR"value="oscar"/>
</databaseIdProvider>
In addition to the configuration method, databaseIdProvider can be injected when SqlSessionFactory of mybatis is configured, and example codes are as follows, < bean id= "sqlSessionFactory" class= "org. Mybatis. Spring. SqlSessionFactoryBean" >
<property name="databaseIdProvider">
<bean class="org.apache.ibatis.mapping.VendorDatabaseIdProvider">
<property name="properties">
<props>
<prop key="MySQL">mysql</prop>
<prop key="OSCAR">oscar</prop>
<prop key="DM DBMS">dm</prop>
</props>
</property>
</bean>
</property>
</bean>
It should be noted that, by adding databaseIdProvider to mybati mybatis-config.xml file and injecting databaseIdProvider when mybatis SqlSessionFactory is configured, configuration of database vendor identification can be achieved.
In one embodiment of the present disclosure, if a plurality of databases to be compatible include databases of the same type and different versions, determining database identifiers of the databases according to version numbers of the plurality of databases, defining database identifiers of the plurality of databases according to a preset rule at an interface of database manufacturer identifiers in a specified frame structure, configuring database manufacturer identifiers corresponding to the plurality of databases in a configuration file of the specified frame structure, so that the database identifiers are effective in the specified frame structure through the configured database manufacturer identifiers, and performing database attribute identifiers on a plurality of SQL statements according to the plurality of database identifiers.
That is, since the database product names of different versions of the same database may be different, the product names of different versions can be unified by custom rules. The custom rule is that, first, the databaseIdProvider interface needs to be implemented, and setProperties () and getDatabaseId () method functions are rewritten, it needs to be noted that, setProperties () method functions are used to represent database information of the database, for example, connection mode, port number, user password, etc. of the database, getDatabaseId () method functions are used to customize DatabaseId, and the type, name, and version number of the database can be defined.
Examples of codes are as follows:
Thereafter, register databaseIdProvider in mybatis-config.xml configuration file, validate databaseId defined in the above step by configuration databaseIdProvider, code examples are as follows:
<databaseIdProvidertype="com.genersoft.mybatis.databaseid.LcDatabaseIdProvider">
<property name="MySQL"value="mysql"/>
<property name="DM DBMS"value="dm"/>
<property name="OSCAR"value="oscar"/>
</databaseIdProvider>
by introducing databaseIdProvider, SQL for different databases can be identified.
Step S103, determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases identified by the database manufacturer.
The SQL sentences executed by different databases are different, and it should be noted that the difference here may refer to databases of different types, or databases of the same type and different versions, and a plurality of SQL sentences corresponding to a plurality of databases are determined according to the manufacturer identification of the databases and grammar information corresponding to the different databases.
Step S104, if the determined SQL sentences are incompatible in the databases, carrying out database attribute identification on the SQL sentences of the databases according to the database manufacturer identification so as to facilitate the appointed framework structure to execute the SQL sentences respectively corresponding to the databases according to the database attribute identification and realize the compatibility of the databases.
In one embodiment of the present disclosure, when determining a plurality of SQL statements corresponding to a plurality of databases, determining whether the plurality of SQL statements are compatible in the plurality of databases according to types of the plurality of SQL statements, where each type of SQL statement includes a general statement and a non-general statement. If the plurality of SQL sentences have non-general sentences, the plurality of SQL sentences are incompatible in the plurality of databases; if the SQL sentences are all general sentences, the SQL sentences are compatible in the databases. It should be noted that, the plurality of databases correspond to a plurality of SQL statements, where the SQL statements may be regarded as a generic term of all the statements, each SQL statement includes a general statement and a non-general statement, and the general statement may be a general SQL statement.
In one embodiment of the present disclosure, if the determined plurality of SQL statements are compatible in the plurality of databases, that is, each SQL statement is a generic statement, then when different databases are connected, the generic statement is executed by MyBatis to achieve multi-database compatibility.
In one embodiment of the present disclosure, if the determined plurality of SQL statements are incompatible in the plurality of databases, that is, each SQL statement includes a non-generic statement, then the database attribute identification needs to be performed on the plurality of SQL statements of the plurality of databases according to the database vendor identification.
In one embodiment of the present disclosure, databaseId attributes may be added to multiple SQL statements corresponding to multiple databases, to implement database attribute identification. That is, corresponding SQL is written according to grammar for different databases for the same DAO interface in the xml configuration file of MyBatis, and the system executes specified SQL according to the actual database type. For example, in mapper. Xml, the SQL add databaseId attribute nodes are distinguished, keeping attributes like id, parameterType, resultType (or resultMap) of multiple statements the same, the only difference being databaseId, the code example is as follows:
<select id="getDataList"resultType="map"parameterType="map"databaseId="mysql">
</>
<select id="getDataList"resultType="map"parameterType="map"databaseId="dm">
</>
<select id="getDataList"resultType="map"parameterType="map"databaseId="oscar">
</>
It should be noted that, when the statement in the SQL statement is general SQL, the SQL does not need to be added with databaseId attributes, and if a plurality of SQL statements comprise a plurality of SQL with the same databaseId, no matter which database is connected, the SQL without adding databaseId attributes can be shielded.
Instead of adding in the corresponding sentences of each database, a dynamic SQL mode can be adopted. In one embodiment of the specification, an if function is used to add corresponding database identifiers to a plurality of non-general sentences, database attribute identifiers are performed on the plurality of non-general sentences to generate a plurality of identified non-general sentences, and the identified SQL sentences corresponding to the plurality of databases are determined according to the general sentences in the plurality of SQL sentences and the plurality of identified non-general sentences.
That is, the SQL is reduced by the dynamic SQL in MyBatis, and the < if test= "_ databaseId =" > "statement is used to match different databases by the parameter_ databaseId. databaseId are identical to databaseId above. The method has the advantages that when the service function requirement is changed, a plurality of SQL (structured query language) does not need to be modified, and the method is as follows:
<if test="_databaseId=='mysql'">
</if>
<if test="_databaseId=='dm'">
</if>
<if test="_databaseId=='oscar'">
</if>
Specifically, if functions are used to add corresponding database identifiers to a plurality of non-general sentences respectively, database attribute identifiers are carried out on the plurality of non-general sentences, and a plurality of identified non-general sentences are generated. For example, the sentences corresponding to the first database are non-general sentences A, general sentences B and general sentences C, the sentences corresponding to the second database are non-general sentences D, general sentences B and general sentences C, then the database attribute identifiers corresponding to the first database are added to the non-general sentences A, the database attribute identifiers corresponding to the second database are added to the non-general sentences D, the identified non-general sentences A1 and the identified non-general sentences D1 are obtained, and SQL sentences compatible with the two databases can be roughly expressed as (the identified non-general sentences A1\the identified non-general sentences D1), general sentences B and general sentences C. When the connection database is a first database, the identified non-general statement A1, general statement B and general statement C are executed, and when the connection database is a second database, the identified non-general statement D1, general statement B and general statement C are executed.
The implementation of the second embodiment of the present disclosure corresponds to the embodiment of the foregoing method, and provides another implementation method for multi-database compatibility of an application program, as shown in fig. 2, in order to implement that the application program can be compatible with multiple databases in the use process, myBatis, myBatis is introduced into the java application program to support custom SQL, storage process and advanced mapping during program development, and MyBatis can execute different sentences according to different database manufacturers.
Since MyBatis can execute different statements according to different database VENDORs, the support of multiple VENDORs is based on databaseId attributes in the mapping statement, so that the database VENDOR identification (databaseIdProvider) needs to be configured to enable databaseId attributes to be effective, wherein the configuration method comprises the following three modes that databaseIdProvider is added in mybati configuration file MyBatis-config.xml file, and the DB_VENDOR implementation corresponding to databaseIdProvider type = "DB_VENDOR"/>, databaseIdProvider sets databaseId as a character string returned by DatabaseMetaData # getDatabaseProductName (). Since these strings are typically very long and different versions of the same product return different values, they can be made shorter by setting the attribute alias.
The second is to inject databaseIdProvider when configuring SqlSessionFactory of mybatis. Thirdly, using custom rule configuration databaseIdProvider, specifically, firstly, needing to implement databaseIdProvider interface, rewriting setProperties () and getDatabaseId () method functions, then adding databaseIdProvider in mybati configuration file mybatis-config.xml file, and implementing configuration database manufacturer identification.
And then judging whether the SQL statement is a general statement, if the SQL statement is a non-general statement, writing corresponding SQL according to different grammar for different databases by the same DAO interface in the xml configuration file, executing appointed SQL according to the actual database type by the system, writing different SQL according to different databases, and adding databaseId attributes in the SQL, so that the readability of the program is high. SQL can also be simplified by means of dynamic SQL in MyBatis, and the < if test= "_ databaseId =" > "statement is used to match different databases by means of parameter_ databaseId. And databaseId is identical to databaseId above. In this way, multiple SQL statements do not need to be modified when business function requirements change. It should be noted that, when the SQL is general-purpose SQL, the attribute databaseId need not be added to the SQL.
By introducing a specified framework structure and configuring database manufacturer identifiers in the framework structure, database attribute identifiers are carried out on SQL sentences according to the database manufacturer identifiers, when multiple databases are connected, corresponding SQL sentences can be executed according to the connected databases, compatibility of the multiple databases is realized, when business codes are required to be modified, database compatibility can be realized by only configuring the corresponding database manufacturer identifiers and adding database attributes to the corresponding SQL sentences.
Embodiments of the present disclosure also provide a multi-database compatible implementation device for an application program, as shown in FIG. 3, comprising at least one processor, and
A memory communicatively coupled to the at least one processor, wherein,
The memory stores instructions executable by the at least one processor, the instructions are executable by the at least one processor to enable the at least one processor to:
The method comprises the steps of introducing a specified framework structure in the development process of an application program, configuring database manufacturer identifications corresponding to a plurality of databases in the specified framework structure, determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases of the database manufacturer identifications, and if the determined SQL sentences are incompatible in the databases, carrying out database attribute identification on the SQL sentences of the databases according to the database manufacturer identifications so as to facilitate the specified framework structure to execute the SQL sentences corresponding to the databases according to the database attribute identifications, thereby realizing compatibility of the databases.
The present specification embodiments also provide a non-volatile computer storage medium storing computer-executable instructions configured to:
the method comprises the steps of introducing a specified framework structure in the development process of an application program, configuring database manufacturer identifications corresponding to a plurality of databases in the specified framework structure, determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases of the database manufacturer identifications, and if the determined SQL sentences are incompatible in the databases, carrying out database attribute identification on the SQL sentences of the databases according to the database manufacturer identifications so as to facilitate the specified framework structure to execute the SQL sentences respectively corresponding to the databases according to the database attribute identifications, thereby realizing compatibility of the databases.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for apparatus, devices, non-volatile computer storage medium embodiments, the description is relatively simple, as it is substantially similar to method embodiments, with reference to the section of the method embodiments being relevant.
The foregoing describes specific embodiments of the present disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
The foregoing is merely one or more embodiments of the present description and is not intended to limit the present description. Various modifications and alterations to one or more embodiments of this description will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, or the like, which is within the spirit and principles of one or more embodiments of the present description, is intended to be included within the scope of the claims of the present description.

Claims (6)

1. A method for implementing multiple database compatibility of an application program, the method comprising:
introducing a specified framework structure in the development process of the application program;
Configuring database manufacturer identifiers corresponding to a plurality of databases in the appointed framework structure;
Determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases identified by the database manufacturer;
If the determined SQL sentences are incompatible in the databases, carrying out database attribute identification on the SQL sentences of the databases according to the database manufacturer identification so as to facilitate the appointed framework structure to execute the SQL sentences respectively corresponding to the databases according to the database attribute identification and realize the compatibility of the databases;
The configuration of vendor identifiers corresponding to various databases in the specified framework structure specifically comprises the following steps:
If a plurality of databases to be compatible comprise databases of the same type and different versions, determining database identifiers of the plurality of databases according to the version numbers of the plurality of databases;
defining database identifiers of the databases according to preset rules at interfaces of database manufacturer identifiers in the appointed framework structure;
Configuring database manufacturer identifiers corresponding to the plurality of databases in a configuration file of the appointed framework structure so as to enable the database identifiers to take effect in the appointed framework structure through the configured database manufacturer identifiers, and carrying out database attribute identification on the plurality of SQL sentences according to the plurality of database identifiers;
Determining a plurality of SQL sentences of the databases according to grammar information corresponding to the databases identified by the database manufacturer, wherein the SQL sentences concretely comprise the following steps:
determining the database type according to the database identifiers corresponding to the databases at a DAO layer of the appointed framework structure;
Determining SQL sentences corresponding to the database according to the database grammar information corresponding to the database types;
before the database attribute identification is performed on the SQL sentences of the databases according to the database manufacturer identification, the method further comprises:
judging whether the SQL sentences are compatible in the databases or not according to the types of the SQL sentences, wherein the types of each SQL sentence comprise general sentences and non-general sentences;
if the plurality of SQL sentences have non-universal sentences, the plurality of SQL sentences are incompatible in the plurality of databases;
If the SQL sentences are all general sentences, the SQL sentences are compatible in the databases;
If the determined SQL sentences are incompatible in the databases, identifying database attributes of the SQL sentences of the databases according to the database manufacturer identification, wherein the method specifically comprises the following steps of:
Respectively adding corresponding database identifiers into the plurality of non-general sentences by using an if function, and carrying out database attribute identification on the plurality of non-general sentences to generate a plurality of identified non-general sentences;
And determining the identified SQL sentences corresponding to the databases according to the general sentences in the SQL sentences and the identified non-general sentences.
2. The method for implementing multi-database compatibility of an application program according to claim 1, wherein said configuring vendor identifiers corresponding to a plurality of databases in said specified framework structure specifically comprises:
If a plurality of databases to be compatible are databases of different types, determining database manufacturer identifiers corresponding to the plurality of databases according to the types of the plurality of databases;
Configuring database manufacturer identifiers corresponding to the various databases in the configuration file of the specified framework structure;
and introducing database identifiers respectively corresponding to the plurality of databases through the database manufacturer identifiers so as to conveniently identify database attributes of the plurality of SQL sentences according to the plurality of database identifiers.
3. The method for implementing multiple database compatibility of an application program according to claim 1, wherein said method further comprises, before introducing a specified framework in a development process of said application program:
determining the data type of a database to be compatible according to the data object of the database;
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 a text type;
when the data object is a digital type, the data type is a decmal type;
When the length of the word segment 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 a varchar type.
4. A multi-database compatible implementation of an application program as claimed in claim 1, the method is characterized in that the databases are all domestic databases.
5. A multi-database compatible implementation device for an application program, the device comprising:
at least one processor, and
A memory communicatively coupled to the at least one processor, wherein,
The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-4.
6. A non-transitory computer storage medium storing computer executable instructions configured to perform the method of any one of claims 1-4.
CN202111456754.4A 2021-12-01 2021-12-01 A method, device and medium for implementing multi-database compatibility of an application program Active CN114138815B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111456754.4A CN114138815B (en) 2021-12-01 2021-12-01 A method, device and medium for implementing multi-database compatibility of an application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111456754.4A CN114138815B (en) 2021-12-01 2021-12-01 A method, device and medium for implementing multi-database compatibility of an application program

Publications (2)

Publication Number Publication Date
CN114138815A CN114138815A (en) 2022-03-04
CN114138815B true CN114138815B (en) 2025-09-12

Family

ID=80386916

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111456754.4A Active CN114138815B (en) 2021-12-01 2021-12-01 A method, device and medium for implementing multi-database compatibility of an application program

Country Status (1)

Country Link
CN (1) CN114138815B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117609178A (en) * 2023-10-08 2024-02-27 中信数字创新(上海)科技有限公司 An application-oriented heterogeneous database compatible implementation system

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111241065A (en) * 2020-01-13 2020-06-05 大汉软件股份有限公司 Security multi-compatibility lightweight database adaptation development and operation device supporting domestic database

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8458201B2 (en) * 2005-04-08 2013-06-04 International Business Machines Corporation Method and apparatus for mapping structured query language schema to application specific business objects in an integrated application environment
CN110287208A (en) * 2019-05-27 2019-09-27 北京三快在线科技有限公司 Method, device and storage medium for database field encryption
CN112948338B (en) * 2021-03-05 2023-04-14 浪潮云信息技术股份公司 Method and tool for operating government data sharing and exchange platform in localized database
CN113535723A (en) * 2021-07-13 2021-10-22 杭州安恒信息技术股份有限公司 Multi-tenant database management and control method, system and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111241065A (en) * 2020-01-13 2020-06-05 大汉软件股份有限公司 Security multi-compatibility lightweight database adaptation development and operation device supporting domestic database

Also Published As

Publication number Publication date
CN114138815A (en) 2022-03-04

Similar Documents

Publication Publication Date Title
US7676492B2 (en) Migration of database using serialized objects
US8392880B2 (en) Rapid application development for database-aware applications
US9465590B2 (en) Code generation framework for application program interface for model
US10437564B1 (en) Object mapping and conversion system
CN102279750B (en) Iterative code generation method based on domain knowledge sharing
US9043757B2 (en) Identifying differences between source codes of different versions of a software when each source code is organized using incorporated files
US20110010700A1 (en) Virtualization of configuration settings
US8695006B2 (en) Resource management method
US10997131B1 (en) Using a member attribute to perform a database operation on a computing device
CN113138792B (en) Elasticsearch version migration method, device and storage medium
CN102054034A (en) Implementation method for business basic data persistence of enterprise information system
CN113468204A (en) Data query method, device, equipment and medium
CN104050161A (en) Dynamic bridging of application and data servers
US8244778B1 (en) Customization of types using default aspects
CN114138815B (en) A method, device and medium for implementing multi-database compatibility of an application program
CN102289448B (en) The entity of visit data access layer
US20090138621A1 (en) System and method for delegating a dependent business object
CN114385145A (en) A Web system back-end architecture design method and computer equipment
CN115344569A (en) Database query method, device and equipment
CN119201885A (en) Metadata migration method and device between databases, storage medium, and equipment
CN114416090A (en) A method and device for converting a single-page application framework Vue component
CN116627390B (en) ICD file substitution method and device in aviation software development
Kumari et al. Database Connection Technology.
CN117372182B (en) Insurance management system based on rapid development persistent layer code auxiliary method
CN112988136B (en) User interface editing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant