Method, device and medium for implementing unified interface access to relational databases
Through object-oriented programming technology, the database object components are encapsulated, and a unified development and call interface is provided, which solves the duplicate development and complexity problems caused by differences in different database interfaces, and realizes standardized database access across platforms and cross-languages, supports multiple database systems, and improves the enterprise's technical standardization and operation and maintenance efficiency.
Patent Information
- Application Number
- CN202311108071.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2043-08-31
AI Technical Summary
The database call interfaces of different manufacturers vary greatly. Enterprise R&D needs to customize different packaging interfaces for different databases, resulting in duplicate development, uneven code quality, difficult to guarantee standardization and reliability, and high complexity of database access across platforms and cross-languages.
The basic object components are encapsulated using object-oriented programming technology, providing a unified development and call interface OCI, supporting cross-platform (Unix, Linux, Windows) and cross-language (C++/C, Java) access, using parameter configuration table definition to access different relational databases, combining creative design patterns and factory method patterns, blocking interface differences and achieving standardized and consistent access.
It realizes unified database access across platforms and languages, reduces development complexity and operation and maintenance costs, supports a variety of relational databases, including domestic databases, has flexibility and scalability, high reliability, avoids duplicate development, and improves the level of technical standardization and operation and maintenance intelligence within the enterprise.
Smart Images

Figure CN117271631B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for accessing a relational database, and more particularly to a method, device, and medium for implementing a unified interface access to a relational database. Background Art
[0002] The importance of large or medium-sized relational database systems is self-evident, and they have extremely wide applications in different industries and various fields. The usability, reliability, and stability of relational database interfaces also play a crucial role. Implementing a general, standardized, and unified database access interface for object-oriented programming is a key component for enterprises to process data.
[0003] Currently, domestic enterprises have a more urgent need for key core basic software such as domestic operating systems and domestic databases. Implementing a set of basic software code that can be cross-compiled across platforms and supporting domestic operating systems and domestic databases is even more important.
[0004] Basic software ODML (operating system, database, middleware, programming language) lies between the application layer and the hardware. To establish a healthy business environment, basic software is indispensable. Without basic software as a hub in any system, even with high-performance hardware and good application software, it cannot operate.
[0005] There are many differences in the database call interfaces of different manufacturers. It is impossible for the products developed by enterprises to customize different encapsulated interfaces for different databases. How to better conceive and develop a new generation of database interface access layers is also what the current R & D technical team needs to overall architect and design from the top layer of database software.
[0006] As group enterprises continue to grow and expand, barriers often form between R & D technical departments. For example, the phenomenon of repeated development in the basic software database interface layer often occurs, and the code quality is uneven, making it difficult to ensure standardization and reliability.
[0007] How to design a general database interface framework to avoid the risks of independent and repeated development in different departments of the entire enterprise, reduce the complexity of the R & D process, and improve the level of intelligent operation and maintenance has become a technical problem to be solved. Summary of the Invention
[0008] The purpose of the present invention is to provide a method, device, and medium for implementing a unified interface access to a relational database to overcome the defects of the above-mentioned existing technologies.
[0009] The purpose of the present invention can be achieved by the following technical solutions:
[0010] According to the first aspect of the present invention, a method for implementing a unified interface access to a relational database is provided, and the method includes:
[0011] Use object - oriented programming technology to effectively encapsulate each basic object component, and provide a general and standardized consistent development call interface OCI;
[0012] Execute SQL standard statements according to the standard language of relational databases, query and access data sets or execute database operation procedures, and access through a unified interface;
[0013] According to the requirements of different operating systems, support adaptive selection of Unix, Linux, and Windows operating systems for compilation to achieve cross - platform functionality of object - oriented interfaces;
[0014] According to the requirements of different programming languages, use C++ / C language as the basis to further encapsulate to adapt to the programming requirements of different languages and achieve cross - language functionality of object - oriented interfaces.
[0015] The said standardization and consistency are based on a general database interface framework, avoiding independent and repetitive development in different departments of the entire enterprise, reducing the complexity of technical implementation and the operation and maintenance costs, and minimizing the interface risks of using the database.
[0016] As a preferred technical solution, the basic object components include a connection object Connection, a command object Command, a cursor object Cursor, a field object Filed, and a parameter object Parameter.
[0017] As a preferred technical solution, the connection object Connection includes Connect, Disconnect, Commit, Rollback, and Option functions. The Connect function includes a connection string, a user name, a password, and a database type; the Option function sets the option functions required by the database;
[0018] The command object Command includes open, close, setConnection, setCommandText, Prepare, Execute, Cancel operation methods, data traversal access FetchNext, FetchPrior, FetchFirst, FetchLast functions, and a function Field for obtaining the returned result set;
[0019] The cursor object Cursor includes operation methods such as open, close, Prepare, Execute, and Cancel, and data traversal and access functions such as FetchNext, FetchPrior, FetchFirst, and FetchLast. The Cursor constructor parameters include Connection and Command;
[0020] The field object Filed and the parameter object Parameter include functions such as Option, Pos, Name, Type, Size, Precision, and Scale.
[0021] As a preferred technical solution, during the call process and the execution statement process of each of the basic objects, object-oriented programming is provided to capture exception handling and print detailed information on the error code and related description of the exception.
[0022] As a preferred technical solution, each of the basic objects is a basic class in object-oriented programming, and different types of databases are further inherited and encapsulated based on the basic class according to requirements.
[0023] As a preferred technical solution, the development call interface OCI applies the characteristics of dynamic link libraries in the operating system, that is, the explicit call method of pointer functions is adopted. Different types of databases are derived based on the basic objects, and different databases are accessed based on the OCI pointer functions.
[0024] As a preferred technical solution, the standard languages of the relational database include the database query language DQL, the database schema definition language DDL, the data manipulation language DML, the data control language DCL, and the transaction control language TCL.
[0025] As a preferred technical solution, the database query language DQL refers to statements with keywords SELECT, FROM, WHERE, and ORDER BY;
[0026] The database schema definition language DDL refers to statements with keywords CREATE, DROP, and ALTER;
[0027] The data manipulation language DML refers to statements with keywords INSERT, UPDATE, and DELETE;
[0028] The data control language DCL refers to statements with keywords RANT and REVOKE;
[0029] The transaction control language TCL refers to statements with keywords COMMIT and ROLLBACK.
[0030] As a preferred technical solution, the support adapts to Unix, Linux, and Windows operating systems, follows the Portable Operating System Interface (POSIX) standard, and realizes cross-platform porting on the same set of codes.
[0031] As a preferred technical solution, the support for the requirements of different programming languages is based on JNI (Java Native Interface) to ensure convenient porting of the code in the JAVA language. The component release version is finally provided to user developers in the form of dynamic link libraries.
[0032] As a preferred technical solution, the relational databases supported by this method include Oracle, Mysql, PostgreSQL, the domestic database DM, and the local file database SQlite. A parameter configuration table is used to define the access to the corresponding relational databases.
[0033] As a preferred technical solution, the definition of the parameter configuration table is specifically as follows:
[0034] The interface parameters defined in the modified file support different relational databases to access different types of database tablespaces. The interface parameters include database name, database type, host address, user, password, port, and character set.
[0035] As a preferred technical solution, the character set defined in the parameter configuration table is defined through parameter configuration options (such as GBK, GB2312, UTF-8, etc.), and the required character set is internally selected based on the database OCI at the bottom layer; and / or the character set defined in the parameter configuration table realizes the translation of string descriptions into the local language through the iconv open-source library.
[0036] As a preferred technical solution, according to the software design pattern, object-oriented interface programming uses the creational design pattern to decouple the client and the specific implementation class.
[0037] As a preferred technical solution, the software design pattern is based on the idea of the abstract factory pattern, providing an interface for creating a series of related dependent objects without specifying their specific classes. The client operates on the instances through their abstract interfaces, and the specific class names of the products are also separated from the implementation of the specific factory.
[0038] As a preferred technical solution, the software design pattern is based on the idea of the factory method pattern, defining an interface for creating objects, allowing subclasses to decide which class to instantiate during runtime. The factory pattern delays the instantiation of a class to its subclasses.
[0039] According to a second aspect of the present invention, there is provided an electronic device, including a memory and a processor, where a computer program is stored on the memory, and when the processor executes the program, the method described above is implemented.
[0040] According to a third aspect of the present invention, there is provided a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method described above is implemented.
[0041] Compared with the prior art, the present invention has the following advantages:
[0042] 1) Based on object-oriented programming technology, the present invention can shield the differences of each database interface OCI, reducing the complexity of database access.
[0043] 2) The object-oriented access method of the present invention can support common relational database systems such as Oracle, mysql, PostgreSQL, SQlite, etc., realizing a set of general and standardized object-oriented access mechanisms, which have the characteristics of simple operation and flexible application.
[0044] 3) The object-oriented interface access of the present invention supports domestic database systems such as DM database. Based on the object-oriented interface access technology of the present invention, more types of domestic database systems can be easily integrated, and the relational database character set can be specified through parameter configuration options to meet the requirements of internationalization of language encoding.
[0045] 4) The present invention has a flexible extension framework function. The newly encapsulated database interface has no impact on the existing solution and will not change the original programming interface calls and accesses.
[0046] 5) The present invention supports operating systems such as Unix, Linux, and Windows and has cross-platform capabilities.
[0047] 6) The present invention can support a more diverse range of relational database systems. The newly added database components only need to be internally organized and encapsulated, without modifying any framework code, and can be quickly integrated in the existing development mode. It is applicable to all systems related to relational database access. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 Schematic diagram of database types supported by the interface;
[0049] Figure 2 Schematic diagram of the classification of standard SQL languages;
[0050] Figure 3 Schematic diagram of the access relationship of the object interface;
[0051] Figure 4Schematic diagram of the process for executing DQL query statements;
[0052] Figure 5 Schematic diagram between "DM" database objects;
[0053] Figure 6 Schematic diagram of the JNI interface access layer;
[0054] Figure 7 Schematic diagram of parameter configuration file options;
[0055] Figure 8 Schematic diagram of heterogeneous database access;
[0056] Figure 9 Schematic diagram of object - oriented interface design. Specific implementation manners
[0057] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0058] The method for implementing unified interface access for a relational database of the present invention includes:
[0059] According to the characteristics of object - oriented programming technology, effectively encapsulate each basic object component, and provide a general and standardized consistent development call interface OCI;
[0060] According to the standard language of the relational database, SQL standard statements can be executed to query and access data sets or perform database operation processes, and the usage method of the unified interface access application is unified;
[0061] According to the requirements of different operating systems, support the adaptive selection of Unix, Linux, Windows operating systems for compilation to achieve the cross - platform function of the object - oriented interface;
[0062] According to the requirements of different programming languages, using C++ / C language as the basis, it can be further encapsulated to adapt to the programming requirements of different languages and achieve the cross - language function of the object - oriented interface;
[0063] According to the classification of database types, a variety of supported database forms and rich types are available. The parameter configuration table can be used to define the access to the corresponding relational databases: Oracle, Mysql, PostgreSQL, etc.;
[0064] According to the software design pattern, object-oriented interface programming uses the creational design pattern to decouple the client and the concrete implementation class, without the need to consider the complex situation of the creation process of some objects.
[0065] In terms of the scope of use of relational databases, separating the implementation of abstract interfaces from object instantiation, the real-time method of object-oriented interface access to relational databases has a very wide range of applications, and is applicable to all application fields where the project business implemented is related to the relational database system.
[0066] The configuration file related to the database system of the present invention is used to specify the name of the relational database instance to be accessed, user account, user password, database port, database type, character set, connection timeout, etc. The local file database uses a provided connection string.
[0067] The object-oriented interface access layer provided by the present invention has cross-platform and cross-language capabilities. It supports Unix, Linux, and Windows operating systems, including domestic Linux operating system series. It supports C++ and Java programming languages.
[0068] Different relational database system instances usually provide language environment settings to specify the language of the relational database system, such as Simplified Chinese (GBK / GB2312), Arabic (UTF-8), etc. The character set option in the parameter configuration file can ensure that the client correctly displays the required encoding format.
[0069] The object-oriented interface access layer of the present invention supports mainstream relational databases such as Oracle, MySQL, PostgreSQL, and SQLite. In addition, it also supports domestic DM databases. Based on the OCI interface definition, encapsulation of other relational databases can be derived.
[0070] The object-oriented interface access layer of the present invention connects objects such as Connection, Command, Cursor, Filed, and Parameter. They are all highly abstracted basic components. All newly added database objects are limited to internal calls and will not affect external use and code modification.
[0071] Based on object-oriented programming technology, the differences between various database interfaces can be shielded, reducing the complexity of database access. Through abstract encapsulation of the object-oriented interface access layer, the differences in different relational database open call interfaces (OCI) are shielded. Based on the object function methods of instantiated objects, various operations on database languages can be performed, such as executing statements like DQL, DML, and DDL.
[0072] The object-oriented interface access layer is abstractly encapsulated, and finally a dynamic link library and a static library are generated using a C++ compiler. The extension names of Unix, Linux, and Windows operating systems are different (*.so / *.a, *.dll / *.lib). The access interface layer is provided to users for development in the form of a dynamic link library. The Java language encapsulates the several objects respectively, and uses the JNI interface to access and generate a dynamic link library.
[0073] Based on the software design pattern idea of object-oriented programming (OOP), the abstract factory pattern and the factory method pattern in the creational pattern are used. An interface for creating objects is defined, allowing subclasses to decide which class to instantiate. The factory pattern delays the instantiation of a class to its subclasses, separating the specific process of creating instances from the client.
[0074] The object-oriented interface access layer of the present invention can support a more diverse relational database system. The newly added database components only need to be internally organized and encapsulated, without modifying any framework code, and can be quickly integrated under the existing development mode. It is applicable to all systems related to relational database access.
[0075] The following details the specific implementation process of the present invention with reference to the accompanying drawings:
[0076] As Figure 1 shown, based on the technical characteristics of object-oriented programming, each basic object component is effectively encapsulated, providing a general and standardized consistent open call interface (OCI). libdbsql is provided to developers in the form of a dynamic link library. At the same time, libdbsql supports cross-platform compilation for Unix, Linux, and Windows, realizing the cross-platform function of the object-oriented interface.
[0077] As Figure 2 shown, the standard language of the relational database mainly includes the database query language (DQL), the database schema definition language (DDL), the data manipulation language (DML), the data control language (DCL), and the transaction control language (TCL), which together form the complete language of the database. Each language corresponds to different functions and roles of the database management system.
[0078] As Figure 3As shown, the Connection connection object is responsible for creating a link communication channel with the relational database, and the Command command object is responsible for executing relevant commands. The interface access layer of the encapsulation library is used to perform various operations on the relational database table. For example, execute the DQL query language, such as the database query statement "Select * from table", and return the queried Recordset record set to the client; execute the DML operation language, such as "delete * from table" to delete all records in the table. During the execution of the command by the connection object or the command object, relevant exceptions can be captured.
[0079] As Figure 4 As shown, this figure mainly describes the process of executing the DQL query. As for the execution processes of DDL, DML, and DCL languages, they are basically similar, except that the process of traversing the Recordset data set of the returned result is missing. First, create a database connection object Connection; second, create a command object Command and bind the created connection object to the command object; finally, after successfully executing the SQL statement, the client will receive the expected data set returned by the server.
[0080] As Figure 5 As shown, the domestic database DM is used as an example. The Connection connection object is a basic object-oriented class, and DamengConnection is derived from the basic class Connection; the Cursor cursor object is a basic object-oriented class, and DamengCursor is derived from the basic class Cursor.
[0081] The DamengCursor object uses the function pointers of the native OCI function library of the DM database encapsulated by DamengClient. DamengClient uses the explicit call method of the dynamic link library, that is, pointer functions are used to implement the packaging of each interface. dmoci.dll is the DM dynamic link library, that is, the library distributed for the Windows operating system.
[0082] Based on key modules such as the DamengConnection connection object, DamengCursor cursor object, Command command object, and Field field object, an object-oriented method for accessing the DM database can be constructed. When the project is running, installed, and deployed, the application software libdbsql.dll and dmoci.dll are generally required to be in the same directory. Of course, the location can also be specified using the environment variables of the operating system.
[0083] Design and encapsulate the Connection object module, which mainly includes functions and methods such as Connect, Disconnect, Commit, Rollback, and Option. The Connect function consists of a connection string, user name, password, and database type; the Option function can be used to set the option functions required by the database.
[0084] Design and encapsulate the Command object module, which mainly includes operation methods such as open, close, setConnection, setCommandText, Prepare, Execute, and Cancel; data traversal and access function methods such as FetchNext, FetchPrior, FetchFirst, FetchLast, and the Field function method for obtaining the returned result set, etc.
[0085] Design and encapsulate the Cursor object module, which mainly includes operation methods such as open, close, Prepare, Execute, and Cancel; data traversal and access function methods such as FetchNext, FetchPrior, FetchFirst, FetchLast. The Cursor constructor parameters consist of Connection and Command.
[0086] Design and encapsulate the Field object module and the Parameter object module, specifically
[0087] mainly including function methods such as Option, Pos, Name, Type, Size, Precision, Scale, etc.
[0088] Considering the network problems of distributed systems and handling various abnormal situations of the database. During the call process of each object module and during the execution of statements, exceptions (Exception) can be accurately thrown, enabling the application layer software to capture the exceptions and perform response processing, and providing detailed information content such as the error code number and relevant description of the exceptions.
[0089] Such as Figure 6 As shown, libdbsql uses a C++ compiler to generate dynamic link libraries and static libraries. To meet the needs of different languages, based on JNI (Java Native Interface), it can ensure convenient porting of the code to the JAVA language. The component release version is finally provided to user developers in the form of a dynamic link library. The Java language encapsulates the several objects mentioned above and accesses the C++ dynamic link library interface methods using the JNI interface.
[0090] As Figure 7 shown, the system can access different databases through configuration parameters. As long as the SECTION keyword of the parameters is unique, it can support any number of database service configuration items, and each service configuration item corresponds to a real-time database system container instance.
[0091] The parameter configuration table can be used to specify the types of relational databases to access: ORACLE, MYSQL, PGSQL, DMSQL, SQLITE, etc. The main parameter items include: the name of the database instance, user account, user password, database port, database type, character set, and connection timeout, etc. For the local file database Sqlite, the database path and file can be specified using the provided connection string.
[0092] Relational database system instances usually provide language environment settings to specify the language of the relational database system, such as Simplified Chinese (GBK / GB2312), Arabic (UTF-8), etc. The character set of the parameter configuration file option can ensure that the client correctly displays the required encoding format.
[0093] The language encoding of the local file database uses the UTF-8 format. To ensure that the application software can correctly display the Chinese encoding format, it is necessary to process it in the sqlite class encapsulated at the access interface layer, and the data type to be processed is the specified string. The open-source software iconv can be used to complete the encoding conversion from UTF-8 to GBK (GB2312). In addition to implementing the translation of string descriptions into the local language through the iconv open-source library, Arabic language conversion can also be achieved to meet the international market requirements of the product.
[0094] As Figure 8 shown, based on the object-oriented interface access relational database implementation method, a unified encapsulation class can be used to instantiate different objects to achieve a consistent access method for mainstream databases such as Oracle, Mysql, and PostgreSQL, and it also supports the domestic database DM and the local file database SQlite.
[0095] As Figure 9 shown, based on the abstract factory pattern and factory method pattern in the creational pattern, an interface for creating objects is defined, and the interface is described using pure virtual functions. Different types of databases encapsulate their own subclasses, which inherit from the AbstractClient abstract class, and let the subclasses decide which class to instantiate. The factory pattern delays the instantiation of a class to its subclasses, separating the specific instance creation process from the client.
[0096] An object-oriented interface access layer implementation method, applicable to all systems for accessing relational databases. It presents a generalized, unified, and standardized framework that can support a rich variety of relational database systems. Under the existing development model, various different database systems can be quickly integrated by configuring parameter options.
[0097] The above is an introduction to the method embodiments. The following further illustrates the solution of the present invention through embodiments of electronic devices and storage media.
[0098] The electronic device of the present invention includes a central processing unit (CPU), which can execute various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or computer program instructions loaded from a storage unit into a random access memory (RAM). In the RAM, various programs and data required for device operation can also be stored. The CPU, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.
[0099] Multiple components in the device are connected to the I / O interface, including: an input unit, such as a keyboard, mouse, etc.; an output unit, such as various types of displays, speakers, etc.; a storage unit, such as a disk, optical disc, etc.; and a communication unit, such as a network card, modem, wireless communication transceiver, etc. The communication unit allows the device to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0100] The processing unit executes the various methods and processes described above, such as the method of the present invention. For example, in some embodiments, the method of the present invention can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device via the ROM and / or the communication unit. When the computer program is loaded into the RAM and executed by the CPU, one or more steps of the method of the present invention described above can be executed. Alternatively, in other embodiments, the CPU can be configured to execute the method of the present invention by any other suitable means (e.g., by means of firmware).
[0101] The functions described above herein can be at least partially executed by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), and so on.
[0102] The program code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing devices, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowchart and / or block diagram are implemented. The program codes can be executed entirely on the machine, partially on the machine, executed partially on the machine as an independent software package and partially on a remote machine, or executed entirely on a remote machine or server.
[0103] In the context of the present invention, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0104] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for implementing unified interface access to a relational database, characterized in that, The method includes: Effectively encapsulating each basic object component using object-oriented programming techniques and providing a general and standardized consistent development call interface OCI; Executing SQL standard statements according to the standard language of the relational database, querying and accessing data sets or executing database operation procedures, and accessing through a unified interface; Supporting the adaptive selection of Unix, Linux, and Windows operating systems for compilation according to the requirements of different operating systems to achieve cross-platform functionality of the object-oriented interface; Using C++ / C language as the basis according to the requirements of different programming languages, encapsulating to adapt to the programming requirements of different languages, and achieving cross-language functionality of the object-oriented interface; The basic object components include a connection object Connection, a command object Command, a cursor object Cursor, a field object Filed, and a parameter object Parameter; The connection object Connection includes Connect, Disconnect, Commit, Rollback, and Option functions, where the Connect function includes a connection string, a user name, a password, and a database type; the Option function sets the option functions required by the database; The command object Command includes operation methods such as open, close, setConnection, setCommandText, Prepare, Execute, Cancel, data traversal access functions FetchNext, FetchPrior, FetchFirst, FetchLast, and a function Field for obtaining the returned result set; The cursor object Cursor includes operation methods such as open, close, Prepare, Execute, Cancel, data traversal access functions FetchNext, FetchPrior, FetchFirst, FetchLast, where the Cursor constructor parameters include Connection and Command; The field object Filed and the parameter object Parameter include Option, Pos, Name, Type, Size, Precision, and Scale functions; The standard language of the relational database includes a database query language DQL, a database schema definition language DDL, a data manipulation language DML, a data control language DCL, and a transaction control language TCL; The relational databases supported by this method include Oracle, Mysql, PostgreSQL, the domestic database DM, and the local file database SQlite, and a parameter configuration table is used to define the access to the corresponding relational databases.
2. The unified interface access implementation method for a relational database according to claim 1, wherein, During the call process and the execution statement process of each of the basic objects, object-oriented programming provides exception handling for capturing exceptions and prints the error codes of the exceptions and detailed information about the relevant descriptions.
3. The unified interface access implementation method for a relational database according to claim 1, characterized in that, Each of the basic objects is a basic class in object-oriented programming. Different types of databases inherit and encapsulate based on the basic class according to requirements.
4. A method for implementing unified interface access to a relational database according to claim 1, characterized in that The developed call interface OCI applies the characteristics of the dynamic link library in the operating system, that is, the explicit call method using pointer functions. Different types of databases are derived based on the basic objects and access different databases based on the OCI pointer functions.
5. A method for implementing unified interface access to a relational database according to claim 1, characterized in that, The database query language DQL refers to the statement with keywords SELECT, FROM, WHERE, and ORDER BY; The database schema definition language DDL refers to the statement with keywords CREATE, DROP, and ALTER; The data manipulation language DML refers to the statement with keywords INSERT, UPDATE, and DELETE; The data control language DCL refers to the statement with keywords GRANT and REVOKE; The transaction control language TCL refers to the statement with keywords COMMIT and ROLLBACK.
6. A method for implementing unified interface access to a relational database according to claim 1, characterized in that, The supported operating systems are Unix, Linux, and Windows, following the Portable Operating System Interface (POSIX) standard to achieve cross-platform porting on the same set of code.
7. A method for implementing unified interface access to a relational database according to claim 1, characterized in that, The requirement to support different programming languages is to ensure convenient porting of the code in the JAVA language based on JNI. The component release version is finally provided to user developers in the form of a dynamic link library, where JNI is the Java Native Interface.
8. A method for implementing unified interface access to a relational database according to claim 1, characterized in that, The parameter configuration table is specifically defined as follows: The interface parameters defined in the modified file support different relational databases to access different types of database tablespaces, where the interface parameters include database name, database type, host address, user, password, port, and character set.
9. A method for implementing unified interface access to a relational database according to claim 8, characterized in that The character set defined in the parameter configuration table is defined through parameter configuration options, relying on the internal selection of the required character set at the OCI bottom layer of the database; and / or the character set defined in the parameter configuration table realizes the translation of string descriptions into the local language through the iconv open-source library.
10. A method for implementing unified interface access to a relational database according to claim 1, characterized in that, According to the software design pattern, object-oriented interface programming uses the creational design pattern to decouple the client and the specific implementation class.
11. A method for implementing unified interface access to a relational database according to claim 10, characterized in that, The software design pattern, based on the idea of the abstract factory pattern, provides an interface for creating a series of related dependent objects without specifying the specific class. The client operates the instance through the abstract interface, and the specific class name of the product is also separated from the implementation of the specific factory.
12. A method for implementing unified interface access to a relational database according to claim 10, characterized in that, The software design pattern, based on the idea of the factory method pattern, defines an interface for creating objects, allowing subclasses to decide which class to instantiate during runtime. The factory pattern delays the instantiation of a class to its subclasses.
13. An electronic device, comprising a memory and a processor, wherein a computer program is stored on the memory, characterized in that, When the processor executes the program, it implements the method described in any one of claims 1 to 12.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method described in any one of claims 1 to 12.
Citation Information
Patent Citations
Data access method of oracle relational database based on procedure call interface
CN101359324A
Universal cross-database access method
CN105260403A