CN112231374A - General database drive adaptation interface system - Google Patents

General database drive adaptation interface system Download PDF

Info

Publication number
CN112231374A
CN112231374A CN202010920851.3A CN202010920851A CN112231374A CN 112231374 A CN112231374 A CN 112231374A CN 202010920851 A CN202010920851 A CN 202010920851A CN 112231374 A CN112231374 A CN 112231374A
Authority
CN
China
Prior art keywords
pbdb
database
interface
adaptation
universal
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.)
Pending
Application number
CN202010920851.3A
Other languages
Chinese (zh)
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.)
Yunnan Nantian Electronics Information Corp ltd
BEIJING NANTIAN SOFTWARE CO LTD
Original Assignee
Yunnan Nantian Electronics Information Corp ltd
BEIJING NANTIAN SOFTWARE 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 Yunnan Nantian Electronics Information Corp ltd, BEIJING NANTIAN SOFTWARE CO LTD filed Critical Yunnan Nantian Electronics Information Corp ltd
Priority to CN202010920851.3A priority Critical patent/CN112231374A/en
Publication of CN112231374A publication Critical patent/CN112231374A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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

Landscapes

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

Abstract

A general database drive adaptation interface system is characterized in that an adaptation access interface and an adaptation operation interface are arranged, the adaptation access interface is connected with a certain service system through a service process control engine, the adaptation operation interface is connected with a database and can shield the difference of drive interfaces between different databases to decouple application development and a database calling interface, so that the restriction on manufacturers and versions when a developer selects a new database is relieved, the developer has higher flexibility and freedom, meanwhile, the universality of the system drive adaptation interface system well reduces the system development workload, shortens the project implementation period, and reduces the project implementation cost and the maintenance cost.

Description

General database drive adaptation interface system
Technical Field
The invention relates to a database driving or database calling technology, in particular to a general database driving adaptive interface system, which is characterized in that an adaptive access interface and an adaptive operation interface are arranged, the adaptive access interface is connected with a certain service system through a service process control engine, the adaptive operation interface is connected with a database and can shield the difference of driving interfaces among different databases so as to decouple application development from a database calling interface, thereby being beneficial to relieving the limitation of a developer on manufacturers and versions when the developer selects a new database, leading the developer to have greater flexibility and freedom, simultaneously reducing the system development workload, shortening the project implementation period and lowering the project implementation cost and maintenance cost due to universality.
Background
The database driver is a database calling program specially realized by different database developers (such as Oracle, Mysql, KingBase and the like) aiming at a certain development language environment (such as java or C), and translates the calling language of the database in the corresponding development language into the own database language of each kind of database through the program, and of course, the translation (database driver) is custom-developed by each developer aiming at a uniform interface. The main flow driver comprises an ODBC/JDBC driver interface, a hybrid driver interface and an API interface. ODBC/JDBC driver interface: based on a set of API driving interfaces which are in accordance with the specification, ODBC/JDBC drivers corresponding to the databases need to be installed. Hybrid drive interface: such as Proc by oracle, Db2 prep by Ibm Db2, Db2 bind, KingBase Esql, etc., can be used directly in hybrid programming with development languages. API interface: such as Mysql API interfaces, etc., may be called directly in the development language. Current mainstream databases include Oracle, Mysql, Ibm Db2, KingBase, and others. Because the databases are provided by different manufacturers, the same type of database can be used under various different conditions, the operating system must install corresponding database drivers or deploy development libraries, and developers can use the databases only by correspondingly developing different driver libraries.
In view of the above, the following problems are generally faced when performing related system development: 1) during system development, although the database driver is irrelevant to the application function, the application function of the system cannot be well separated from the database driver, and the tightly coupled mode causes that each new database or each new database needs to be greatly supplemented or modified. 2) During system development, each different database needs to compile corresponding database adaptation codes or perform secondary development, development workload is large, development period is long, and system stability is poor. 3) When the system runs and the database fails, the flexible database switching cannot be carried out, and the maintenance is inconvenient. 4) During system development and operation, different databases have higher requirements on the technical level of development and operation technicians, and the overall cost of the system is increased.
Disclosure of Invention
Aiming at the defects or shortcomings of the prior art, the invention provides a universal database driving adaptation interface system, which is characterized in that an adaptation access interface and an adaptation operation interface are arranged, the adaptation access interface is connected with a certain service system through a service process control engine, the adaptation operation interface is connected with a database and can shield the difference of driving interfaces among different databases so as to decouple application development and a database calling interface, thereby being beneficial to relieving the limitation of a developer on a manufacturer and a version when the developer selects a new database, leading the developer to have greater flexibility and freedom, simultaneously reducing the system development workload, shortening the project implementation period and reducing the project implementation cost and maintenance cost due to the universality.
The technical scheme of the invention is as follows:
the universal database driving adaptation interface system is characterized by comprising an adaptation access interface and an adaptation operation interface, wherein the adaptation access interface is connected with a business system through a business process control engine, and the adaptation operation interface is connected with a database and can shield the difference of driving interfaces among different databases so as to decouple application development from a database calling interface.
The business process control engine comprises the following modules: starting the connection of a database/supporting disconnection reconnection of a certain service system, unpacking a message, increasing/deleting/modifying/checking related database operation, carrying out data processing message packing, communication processing or communication with other systems on the result of the related database operation, unpacking the message, carrying out message packing, and returning a data packet to the certain service system.
The database is a relational database or a distributed database, the relational database comprises Oracle, Mysql, Ibm Db2, Ibm Informix or KingBase of Dajincang, and the distributed database comprises Dlbe of Shanghai, Shanghai puff hotdb, TiDB of Beijing Pinkachen stars, Sequoia giga DB or open source database middleware MyCat.
The adaptation access interface comprises the following: pbDb _ ConnectDatabase () connects the databases; pbDb _ DisconnectDatabase () disconnects the database; pbDb _ commit tran () commits the database; pbDb _ commit release () commits the database and disconnects; pbDb _ RollbackTran () rollback database operation; pbDb _ RollbackRelease () rolls back and disconnects the database.
The adaptation operation interface comprises the following: pbDb _ Insert _ Record () adds a Record; pbDb _ Insert _ Records () Records for additions that support binding mode; pbDb _ Delete _ Record () deletes a Record; pbDb _ Delete _ Records () Records for deletes that support binding mode; pbDb _ Update _ Record () updates the Record; pbDb _ Update _ Records () is directed to Update Records that support binding mode; pbDb _ Select _ Record () query Record; pbDb _ Select _ Records () Records queries that support binding mode; pbDb _ Get _ recordnems () number of acquisition records for a single query; pbDb _ Get _ recordnnumwithsql () counts the number of acquisition records for multiple joint checks.
The system also comprises the following database other interfaces: 1) pbDb _ GetTableCoolNum () acquires the number of fields of the specified table; 2) pbDb _ GetColumnNoByIndexType () acquires the specified table index; 3) pbDb _ CheckTableExists () checks if a table exists; 4) pbDb _ GetTableDef () acquires the specified table definition; 5) pbDb _ GetColumnDef () obtains the specified table column definitions; 6) pbDb _ TableToBuff () derives the assignment table to the cache; 7) pbDb _ TableToFile () imports a specified table into a file; 8) the pbDb _ FileToTable () imports the file into a specified table; 9) pbDb _ TableTo _ String () derives the designation table data to the character String.
The system also comprises the following special processing interfaces: (ii) pbDb _ GenSqlString _ WithPages () paging operation statement; pbDb _ ToChar () string conversion; ③ pbDb _ GenSelFldStr () string splicing; fourthly, date conversion is carried out on pbDb _ ToDateChar (); pbDb _ Get _ DynSequenceNo () sequence operation; sixthly, setting error codes of pbDb _ SetSQLCODE (); seventhly pbDb _ SetSQLMSG () wrong description setting.
The method also comprises the following common function conversion general interfaces of the databases: (1) PBDB _ NVL empty judgment; (2) PBDB _ TOUPPER size conversion; (3) PBDB _ TOUPPER lower case conversion; (4) splicing PBDB _ CONCAT fields; (5) removing left and right spaces from the PBDB _ TRIM field; (6) PBDB _ TOCHAR is converted into a character string; (7) PBDB _ SUM; (8) PBDB _ MAX takes the maximum value; (9) PBDB _ SUBSTR intercepts the character string; (10) the PBDB _ LENGTH character string takes LENGTH; (11) PBDB _ TODATE conversion date; (12) PBDB _ SYSDATE acquires a system date; (13) PBDB _ ADDDATE date of addition; (14) PBDB _ ADDMONTH increase month; (15) PBDB _ ROWNUM acquires a record line number; (16) PBDB _ TOHEX is converted to 16-ary.
The universal database driving adaptation interface API is provided in a database application system through a static library libpbcomm.a and a dynamic library libpbcomm.so as to support multiple operating system versions of AIX/HP-UX/Linux, and for a static library mode, a corresponding API is directly called in a code by compiling and linking a library file to a target program; for the dynamic LIBRARY mode, the LIBRARY file is placed in the directory pointed by the environment variable LD _ LIBRARY _ PATH, and after the LIBRARY file is opened in the code in a dlopen () mode, the corresponding API is directly called.
The common database driven adaptation interface API is customized by the macro at precompilation to support the support differences of different database tables: [1] controlling the LENGTH of an operation statement through the macro MAX _ SQLSTR _ LENGTH; [2] controlling the number of the inserted fields through a macro MAX _ INSERT _ ITEMS; [3] controlling the number of conditions through a macro MAX _ WHERE _ ITEMS; [4] controlling the number of the UPDATE fields through the macro MAX _ UPDATE _ ITEMS; [5] controlling the number of the query fields through a macro MAX _ SELECT _ ITEMS; [6] controlling the SIZE of the number of returned records of the single query through the macro FETCH _ SIZE; [7] the single field return record value size is controlled by the macro MAX _ value _ LENGTH.
The generic database driven adaptation interface includes the following interfaces of the developer custom statements: <1> custom INSERT statement interface INSERT _ stuct. <2> interface DELETE _ STRUCT. sDeleteSql of custom DELETE statement; <3> custom modification statement interface UPDATE _ STRUCT. sUpdateSql; sSelectSql, custom query statement interface SELECT _ STRUCT.
The adaptation operation interface supports dynamic setting and variable binding of added, deleted, changed and checked fields through dynamic arrays to support the difference of whether different databases are bound or not, and for the databases supporting binding, the universal database drives the adaptation interface to automatically generate binding statements according to the fields and conditions transmitted after the developed calling interface, and returns the execution result to a user.
The universal database drive adaptation interface comprises sequence support, different sequence acquisition branches are set and called in an environment variable SEQ _ MODE, and a sequence is efficiently acquired by adding a sequence cache.
The universal database driving adaptation interface comprises a monitoring module, and the monitoring module grasps the running condition of the database driving adaptation interface through the log file of the universal database driving adaptation interface so as to position and analyze the running problem of the universal database adaptation interface.
The invention has the following technical effects: the invention relates to a universal database driving adaptation interface system, which comprises a series of universal APIs (application programming interfaces) for abstracting and refining a database which is in line with the use of domestic developers according to the experience of developing various databases and adapting and writing the databases by the inventor for years. The invention has the following characteristics: 1) the interface specification has wide coverage: the invention is designed aiming at the practical requirement of using the database by the current domestic developers, and basically covers the types and different versions of domestic mainstream databases. 2) Autonomous and controllable: the method starts from the aspects of dealing with system safety risks and implementing autonomous controllable requirements, improves the autonomous research and development capability, realizes autonomous research and development in the key field of the database, and realizes technical breakthrough. 3) The interface specification is flexible to expand: the interface specification designed by the invention has strong expandability and flexible and convenient expansion, can automatically adapt to a specific function interface, and generally only needs to simply adjust/newly add codes to recompile the corresponding database interface library when newly adding or changing different types of databases. 4) Providing a detailed running log: the invention provides a detailed operation log level in the API operation state, can flexibly set and record and set corresponding log level according to the requirement of a developer when a service or a program is in the operation state, is convenient to record the operation condition of using a database interface, and can quickly position or track the use or operation condition of the database.
The invention has the following advantages: 1) the database product types supported are numerous: the invention supports the mainstream database types in the current market, and the supported database types comprise the following types after full test verification: oracle, Ibm Db2, Mysql, KingBase, etc. 2) The product interfaces supported are numerous: the invention supports the mainstream database interface in the current market, and through sufficient test and verification, the supportable database manufacturers comprise: oracle, IBM DB2, Mysql, KingBase, etc., the interfaces include interfaces that support hybrid-based programming: proc, Esql, isql, Mysql interface based on API, ODBC universal interface based on vendor, etc. 3) The database access mode is simple and convenient: the invention can adapt to various types of databases only by modifying the newly added database based on the universal interface once for the types of databases already supported by the current universal API, and can quickly access the newly added databases supported by other universal interfaces only by simple configuration or recompilation without programming. Meanwhile, a universal interface based on a hybrid programming mode and a unified universal encapsulation interface based on an ODBC driver are provided for different developers, the development complexity of the bottom layer driver is shielded, the developers do not need to know the complex configuration or programming specification of the bottom layer driver or the interface, only need to pay attention to application logic, and the development convenience and simplicity are brought. 4) Support a complex database access mode: the invention supports a plurality of complex database combination connection modes, supports the simultaneous operation of a plurality of different types of databases, and simultaneously supports the operation of the databases with the same type, different databases and different versions on different developers. 5) The operation state switching is flexible: the invention supports the developer end to increase/replace the related database in real time, the database is switched and then is disconnected with the reconnection checking mechanism by the switch in the long connection mode, and the program or service can take effect without restarting, thereby being convenient and flexible. 6) The API interface can be multiplexed, the implementation period is short, and the cost is low: practice proves that the API can be reused to a great extent, and the purposes of shortening the project implementation period and reducing the project implementation cost are achieved.
The related domestic industries are complex in database drive control and development all the time, particularly, along with the rapid development of domestic application, the use scene is more and more complex, the use of the database is more and more extensive, meanwhile, more domestic and foreign database manufacturers enter the market, channels supported by different database manufacturers are different in type, some support API access, some support ODBC or JDBC interfaces through a mixed interface. As more new databases are used in the related application systems, it is a very difficult task to quickly access such many databases into the system and to support the flexible expansion of new vendors, new types, and new versions. The inventor has abundant implementation experience in related fields, carries out a large amount of verification on the basis of an initial API prototype through continuous drilling and practice, continuously carries out perfection and improvement, successfully realizes the design and realization of a universal database drive adaptation interface, successfully applies the universal database drive adaptation interface in a plurality of application systems of a plurality of large developers in China, and obtains good verification in the aspects of accelerating project implementation progress and reducing project implementation cost; compared with other database adapters, the method has obvious leading advantages.
The series of universal database driving adaptation interfaces provided by the invention can well support the database and different versions of the current mainstream database manufacturer; meanwhile, the universal interface has good foresight in design, can be flexibly expanded according to needs, and can be quickly accessed to database products of new types and models; and good technical support is provided for the development of related systems using different databases.
Drawings
FIG. 1 is a schematic diagram of the location of a generic database driven adaptation interface system in a database application system according to the present invention. The database application system in fig. 1 includes a database, which is a relational database (e.g., Oracle, Mysql, Ibm Db2, Ibm Informix, king vault base, etc.) or a distributed database (e.g., Dlbe, shanghai hot puff hotdb, TiDB, seuoqoiadb, my source database middleware, MyCat, etc.), a universal database driving interface, i.e., the universal database driving adapter interface system of the present invention is connected to the database through an adapter operation interface and shields differences of driving interfaces between different databases to decouple application development from a database calling interface, and is connected to a certain service system through an adapter access interface and a service flow control engine, and the service flow control engine includes the following modules: starting the connection of a database/supporting disconnection reconnection of a certain service system, unpacking a message, increasing/deleting/modifying/checking related database operation, carrying out data processing message packing, communication processing or communication with other systems on the result of the related database operation, unpacking the message, carrying out message packing, and returning a data packet to the certain service system.
FIG. 2 is a schematic diagram of a generic database-driven adapter interface system for implementing the present invention. The universal database interface in fig. 2, that is, the universal database driving adaptation interface system of the present invention, includes an adaptation access interface and an adaptation operation interface, the adaptation access interface is connected to a certain service system through a service process control engine, the adaptation operation interface includes a driving adaptation interface based on an Oracle database and a driving adaptation interface based on a Mysql database, the driving adaptation interface based on the Oracle database includes an add data interface/delete data interface/modify data interface/query data interface/sequence operation interface/other operation interfaces, and the driving adaptation interface based on the Mysql database includes an add data interface/delete data interface/modify data interface/query data interface/sequence operation interface/other operation interfaces.
FIG. 3 is a schematic diagram of the operation flow of a generic database driven adapter interface system according to the present invention. Fig. 3 includes a call from the beginning to the generic interface, then to the completion of the service data processing, and finally to the end, where the generic interface call includes a connection database (setting a connection handle, based on api or odbc), a call of an access interface/initialization SQLCODE, a generation sequence/call of an add/delete/modify/check interface according to the service requirement, a call of an access interface/setting SQLCODE and SQLMSG, a completion of the service data operation/a decision of subsequent processing according to SQLCODE, and a release of the database connection generic interface (call according to the service requirement).
FIG. 4 is a diagram of the types of database devices that can be supported by the universal database driven adapter interface system of the present invention and their manufacturers.
Detailed Description
The invention is described below with reference to the accompanying drawings (fig. 1-4).
FIG. 1 is a schematic diagram of the location of a generic database driven adaptation interface system in a database application system according to the present invention. FIG. 2 is a schematic diagram of a generic database-driven adapter interface system for implementing the present invention. FIG. 3 is a schematic diagram of the operation flow of a generic database driven adapter interface system according to the present invention. FIG. 4 is a diagram of the types of database devices that can be supported by the universal database driven adapter interface system of the present invention and their manufacturers. Referring to fig. 1 to 4, a general database driving adaptation interface system includes an adaptation access interface connected to a business system through a business process control engine and an adaptation operation interface connected to a database and capable of shielding differences of driving interfaces between different databases to decouple application development from a database call interface. The business process control engine comprises the following modules: starting the connection of a database/supporting disconnection reconnection of a certain service system, unpacking a message, increasing/deleting/modifying/checking related database operation, carrying out data processing message packing, communication processing or communication with other systems on the result of the related database operation, unpacking the message, carrying out message packing, and returning a data packet to the certain service system. The database is a relational database or a distributed database, the relational database comprises Oracle, Mysql, Ibm Db2, Ibm Informix or KingBase of Dajincang, and the distributed database comprises Dlbe of Shanghai, Shanghai puff hotdb, TiDB of Beijing Pinkachen stars, Sequoia giga DB or open source database middleware MyCat.
The adaptation access interface comprises the following: pbDb _ ConnectDatabase () connects the databases; pbDb _ DisconnectDatabase () disconnects the database; pbDb _ commit tran () commits the database; pbDb _ commit release () commits the database and disconnects; pbDb _ RollbackTran () rollback database operation; pbDb _ RollbackRelease () rolls back and disconnects the database.
The adaptation operation interface comprises the following: pbDb _ Insert _ Record () adds a Record; pbDb _ Insert _ Records () Records for additions that support binding mode; pbDb _ Delete _ Record () deletes a Record; pbDb _ Delete _ Records () Records for deletes that support binding mode; pbDb _ Update _ Record () updates the Record; pbDb _ Update _ Records () is directed to Update Records that support binding mode; pbDb _ Select _ Record () query Record; pbDb _ Select _ Records () Records queries that support binding mode; pbDb _ Get _ recordnems () number of acquisition records for a single query; pbDb _ Get _ recordnnumwithsql () counts the number of acquisition records for multiple joint checks.
The system also comprises the following database other interfaces: 1) pbDb _ GetTableCoolNum () acquires the number of fields of the specified table; 2) pbDb _ GetColumnNoByIndexType () acquires the specified table index; 3) pbDb _ CheckTableExists () checks if a table exists; 4) pbDb _ GetTableDef () acquires the specified table definition; 5) pbDb _ GetColumnDef () obtains the specified table column definitions; 6) pbDb _ TableToBuff () derives the assignment table to the cache; 7) pbDb _ TableToFile () imports a specified table into a file; 8) the pbDb _ FileToTable () imports the file into a specified table; 9) pbDb _ TableTo _ String () derives the designation table data to the character String. The system also comprises the following special processing interfaces: (ii) pbDb _ GenSqlString _ WithPages () paging operation statement; pbDb _ ToChar () string conversion; ③ pbDb _ GenSelFldStr () string splicing; fourthly, date conversion is carried out on pbDb _ ToDateChar (); pbDb _ Get _ DynSequenceNo () sequence operation; sixthly, setting error codes of pbDb _ SetSQLCODE (); seventhly pbDb _ SetSQLMSG () wrong description setting.
The method also comprises the following common function conversion general interfaces of the databases: (1) PBDB _ NVL empty judgment; (2) PBDB _ TOUPPER size conversion; (3) PBDB _ TOUPPER lower case conversion; (4) splicing PBDB _ CONCAT fields; (5) removing left and right spaces from the PBDB _ TRIM field; (6) PBDB _ TOCHAR is converted into a character string; (7) PBDB _ SUM; (8) PBDB _ MAX takes the maximum value; (9) PBDB _ SUBSTR intercepts the character string; (10) the PBDB _ LENGTH character string takes LENGTH; (11) PBDB _ TODATE conversion date; (12) PBDB _ SYSDATE acquires a system date; (13) PBDB _ ADDDATE date of addition; (14) PBDB _ ADDMONTH increase month; (15) PBDB _ ROWNUM acquires a record line number; (16) PBDB _ TOHEX is converted to 16-ary. The universal database driving adaptation interface API is provided in a database application system through a static library libpbcomm.a and a dynamic library libpbcomm.so as to support multiple operating system versions of AIX/HP-UX/Linux, and for a static library mode, a corresponding API is directly called in a code by compiling and linking a library file to a target program; for the dynamic LIBRARY mode, the LIBRARY file is placed in the directory pointed by the environment variable LD _ LIBRARY _ PATH, and after the LIBRARY file is opened in the code in a dlopen () mode, the corresponding API is directly called. The common database driven adaptation interface API is customized by the macro at precompilation to support the support differences of different database tables: [1] controlling the LENGTH of an operation statement through the macro MAX _ SQLSTR _ LENGTH; [2] controlling the number of the inserted fields through a macro MAX _ INSERT _ ITEMS; [3] controlling the number of conditions through a macro MAX _ WHERE _ ITEMS; [4] controlling the number of the UPDATE fields through the macro MAX _ UPDATE _ ITEMS; [5] controlling the number of the query fields through a macro MAX _ SELECT _ ITEMS; [6] controlling the SIZE of the number of returned records of the single query through the macro FETCH _ SIZE; [7] the single field return record value size is controlled by the macro MAX _ value _ LENGTH. The generic database driven adaptation interface includes the following interfaces of the developer custom statements: <1> custom INSERT statement interface INSERT _ stuct. <2> interface DELETE _ STRUCT. sDeleteSql of custom DELETE statement; <3> custom modification statement interface UPDATE _ STRUCT. sUpdateSql; sSelectSql, custom query statement interface SELECT _ STRUCT.
The adaptation operation interface supports dynamic setting and variable binding of added, deleted, changed and checked fields through dynamic arrays to support the difference of whether different databases are bound or not, and for the databases supporting binding, the universal database drives the adaptation interface to automatically generate binding statements according to the fields and conditions transmitted after the developed calling interface, and returns the execution result to a user. The universal database drive adaptation interface comprises sequence support, different sequence acquisition branches are set and called in an environment variable SEQ _ MODE, and a sequence is efficiently acquired by adding a sequence cache. The universal database driving adaptation interface comprises a monitoring module, and the monitoring module grasps the running condition of the database driving adaptation interface through the log file of the universal database driving adaptation interface so as to position and analyze the running problem of the universal database adaptation interface.
The invention is designed and appointed from the following aspects in order to achieve the universality of the universal database driving adaptation interface.
The general database driving adaptive interface structure comprises the following steps: as shown in fig. 2, the generic database driver interface provides services to the relevant application modules (performs database operations and returns application data or operation results) upwards and drives the relevant databases (writes or reads database data or execution results) downwards.
The universal database driving adaptation interface is divided into an access interface and an operation interface: 1) the universal database drive adapts the operation access interface, including API of connecting database, disconnecting database, submitting affair, rolling back affair, etc. 2) The general database drives the adaptive operation processing interface: a specific set of general APIs are provided for different databases according to different driving methods of the databases. For example: for an Oracle database, a plurality of APIs are provided, such as adding, deleting, modifying, inquiring, cursor operating, database binding operating, data record paging, acquiring a main key, acquiring an external key, acquiring an index, sequence operating, data importing, data exporting, acquiring database field definition and length and the like.
II, a general database driving interface working process: as shown in fig. 3, the general database driver interface workflow: calling a general drive adaptive access interface (completing connection of databases, setting a connection handle (databases such as mysql, etc., and the access uses a Proc hybrid programming interface to not need the connection handle)), then calling corresponding database general drive interfaces (such as adding data, deleting data, inquiring data, etc.) aiming at different databases, and finally calling a general drive access interface (completing database submission, database disconnection, etc.), and completing the whole process of corresponding database drive.
Designing a general database drive adaptation interface main API:
1. general drive adaptation access interface main API:
1) connecting a database: pbDb _ ConnectDatabase ()
2) Disconnecting the database: pbDb _ DisconnectictDatabase ()
3) Submitting a database: pbDb _ CommitTran ()
4) Submitting the database and disconnecting: pbDb _ CommitRelease ()
5) Rollback database operation: pbDb _ RollbackTran ()
6) Roll back and disconnect database: pbDb _ RollbackRelease ()
2. Database universal drive adaptation operation interface main API:
1) adding records: pbDb _ Insert _ Record ()
2) Add record (support binding mode): pbDb _ Insert _ Records ()
3) And deleting the record: pbDb _ Delete _ Record ()
4) Delete record (binding mode supported): pbDb _ Delete _ Records ()
5) And (3) updating records: pbDb _ Update _ Record ()
6) Update record (binding mode supported): pbDb _ Update _ Records ()
7) And (4) inquiring records: pbDb _ Select _ Record ()
8) Query record (binding mode supported): pbDb _ Select _ Records ()
9) Number of records (single query) obtained: pbDb _ Get _ RecordNums ()
10) Acquiring the recorded number (multiple joint inspection): pbDb _ Get _ RecordNumsWithSql ()
3. Database other interface API:
1) acquiring the number of field pieces of the specified table: pbDb _ GetTableColNum ()
2) Obtaining an appointed table index: pbDb _ GetColumnNoByIndexType ()
3) Check whether the table exists: pbDb _ CheckTableExists ()
4) Get specification table definition: pbDb _ GetTableDef ()
5) Get the specified tabular definition: pbDb _ GetColumDef ()
6) Export the specified table to the cache: pbDb _ TableToBuff ()
7) Import designation table to file: pbDb _ TableToFile ()
8) Import file to specified table: pbDb _ FileToTable ()
9) Export of the assignment table data to strings: pbDb _ TableTo _ String ()
4. Special processing interface API:
1) paging operation statement: pbDb _ GenSqlString _ WithPages ()
2) Character string conversion: pbDb _ ToChar ()
3) Character string splicing: pbDb _ GenSelFldStr ()
4) And (3) date conversion: pbDb _ ToDateChar ()
5) Sequence operation: pbDb _ Get _ DynSequenceNo ()
6) Setting an error code: pbDb _ SetSQLCODE ()
7) Error description setting: pbDb _ SetSQLMSG ()
5. Database common function transformation general API:
1) and (4) empty judgment: PBDB _ NVL
2) Size conversion: PBDB _ TOUPPER
3) And (3) conversion of a lower case: PBDB _ TOUPPER
4) Field splicing: PBDB _ CONCAT
5) Removing left and right spaces from fields: PBDB _ TRIM
6) Conversion to a string: PBDB _ TOCHAR
7) And (3) summing: PBDB _ SUM
8) Taking the maximum value: PBDB _ MAX
9) Intercepting character strings: PBDB _ SUBSTR
10) Length of character string: PBDB _ LENGTH
11) And (3) converting the date: PBDB _ TODATE
12) Acquiring a system date: PBDB _ SYSDATE
13) Adding date: PBDB _ ADDDATE
14) And (4) increasing the month: PBDB _ ADDMONTH
15) Acquiring a record line number: PBDB _ ROWNUM
16) Conversion to 16-ary: PBDB _ TOHEX
Four, universal database driver adaptation interface API usage
1. The application method of the universal database drive adaptation interface API comprises the following steps: the database driver adapter interface API is provided by adopting two modes of a static library (libpbcomm. a) and a dynamic library (libpbcomm. so), and various operating system versions of AIX/HP-UX/Linux are supported. 1) The method has higher execution efficiency for a static library (libpbcomm.a) mode. The library file needs to be compiled and linked to a target program, and a corresponding API is directly called in a code. 2) For the dynamic library (libpbcomm. so) approach, there is better flexibility. The LIBRARY file needs to be placed in a directory pointed by the environment variable LD _ LIBRARY _ PATH, and after the LIBRARY file is opened in a code in a dlopen () mode, the corresponding API is directly called.
2. The general database driver adaptation API interface main structure (add, delete, change, check): in order to support the difference of the number of the support fields of different database table pairs, the length of an operation statement, the size of the storable content of a single field and the like, the macro is customized during precompilation.
Supporting differences of different database tables are supported by the following key compilation macros:
1) controlling the LENGTH of the operation statement by the macro MAX _ SQLSTR _ LENGTH
2) Controlling the number of fields inserted by macro MAX _ INSERT _ ITEMS
3) Controlling the number of conditions by macro MAX _ WHERE _ ITEMS
4) Controlling the number of UPDATE fields by macro MAX _ UPDATE _ ITEMS
5) Controlling the number of fields queried by macro MAX _ SELECT _ ITEMS
6) Controlling the SIZE of the number of records returned by a single query through the macro FETCH _ SIZE
7) Controlling single field return record value size by macro MAX _ value _ LENGTH
And (3) adapting to the complex operation statement through the custom statement: for some scenes with more complex databases, the universal database adapter interface provides an interface for a developer to define a statement, the developer only needs to call the corresponding interface to set, and the interface can automatically judge whether the developer transmits the statement to execute response operation and return a pointing result.
1) Self-defining an insertion statement interface: INSERTS SQl
2) And (3) self-defining a deletion statement interface: DELETE _ STRUCT
3) Self-defining a statement modifying interface: UPDATE _ stuct. supdatesql
4) Self-defining a query statement interface: SELECT _ stuct
The main operation interface structure: in order to support the difference caused by whether different database pairs are bound or not, the dynamic setting and variable binding of the added, deleted, changed and checked fields are supported by the dynamic array. For the database supporting binding, the universal database driving adaptation interface can automatically generate a binding statement according to the field and the condition transmitted after the developed calling interface, and returns the execution result to the user.
1) Plug-in database
Figure BDA0002666683040000121
2) Deleting a database
Figure BDA0002666683040000122
Figure BDA0002666683040000131
3) Modifying a database
Figure BDA0002666683040000132
4) Querying a database
Figure BDA0002666683040000133
Figure BDA0002666683040000141
3. The general database driving adaptive interface sequence supports: different databases have different support sequences, for example, an Oracle support sequence, Mysql and other partial databases do not have native sequence support, and a general database API realizes the support sequences in 4 different ways, but call interfaces are only: pbDb _ Get _ dynasequence no ():
1) sequence mode:
Figure BDA0002666683040000142
2) sequence caching
Figure BDA0002666683040000151
Different sequence acquisition branches are set and called in an environment variable SEQ _ MODE, and the sequence is efficiently acquired by adding sequence cache.
4. Monitoring a universal database drive adaptation interface: the operation condition of the database driving adaptation interface can be mastered by driving the adaptation interface log file through the general database, and meanwhile, the positioning and analysis of the operation problem of the database adaptation interface are facilitated.
Figure BDA0002666683040000152
It is pointed out here that the above description is helpful for the person skilled in the art to understand the invention, but does not limit the scope of protection of the invention. Any such equivalents, modifications and/or omissions as may be made without departing from the spirit and scope of the invention may be resorted to.

Claims (14)

1. The universal database driving adaptation interface system is characterized by comprising an adaptation access interface and an adaptation operation interface, wherein the adaptation access interface is connected with a business system through a business process control engine, and the adaptation operation interface is connected with a database and can shield the difference of driving interfaces among different databases so as to decouple application development from a database calling interface.
2. The universal database driven adaptation interface system according to claim 1, wherein said business process control engine comprises the following modules: starting the connection of a database/supporting disconnection reconnection of a certain service system, unpacking a message, increasing/deleting/modifying/checking related database operation, carrying out data processing message packing, communication processing or communication with other systems on the result of the related database operation, unpacking the message, carrying out message packing, and returning a data packet to the certain service system.
3. The universal database driven adaptation interface system according to claim 1, wherein the database is a relational database or a distributed database, the relational database comprises Oracle, Mysql, Ibm Db2, Ibm Informix or KingBase of gungskin, and the distributed database comprises Dlbe, popped hot and toggle, TiDB, sequoia Db, or MyCat.
4. The universal database driven adaptation interface system according to claim 1, wherein said adaptation access interface comprises the following: pbDb _ ConnectDatabase () connects the databases; pbDb _ DisconnectDatabase () disconnects the database; pbDb _ commit tran () commits the database; pbDb _ commit release () commits the database and disconnects; pbDb _ RollbackTran () rollback database operation; pbDb _ RollbackRelease () rolls back and disconnects the database.
5. The universal database driven adaptation interface system according to claim 1, wherein the adaptation operation interface comprises the following: pbDb _ Insert _ Record () adds a Record; pbDb _ Insert _ Records () Records for additions that support binding mode; pbDb _ Delete _ Record () deletes a Record; pbDb _ Delete _ Records () Records for deletes that support binding mode; pbDb _ Update _ Record () updates the Record; pbDb _ Update _ Records () is directed to Update Records that support binding mode; pbDb _ Select _ Record () query Record; pbDb _ Select _ Records () Records queries that support binding mode; pbDb _ Get _ recordnems () number of acquisition records for a single query; pbDb _ Get _ recordnnumwithsql () counts the number of acquisition records for multiple joint checks.
6. The universal database driven adaptation interface system according to claim 1, further comprising the following database other interfaces: 1) pbDb _ GetTableCoolNum () acquires the number of fields of the specified table; 2) pbDb _ GetColumnNoByIndexType () acquires the specified table index; 3) pbDb _ CheckTableExists () checks if a table exists; 4) pbDb _ GetTableDef () acquires the specified table definition; 5) pbDb _ GetColumnDef () obtains the specified table column definitions; 6) pbDb _ TableToBuff () derives the assignment table to the cache; 7) pbDb _ TableToFile () imports a specified table into a file; 8) the pbDb _ FileToTable () imports the file into a specified table; 9) pbDb _ TableTo _ String () derives the designation table data to the character String.
7. The universal database driven adaptation interface system according to claim 1, further comprising the following special processing interfaces: (ii) pbDb _ GenSqlString _ WithPages () paging operation statement; pbDb _ ToChar () string conversion; ③ pbDb _ GenSelFldStr () string splicing; fourthly, date conversion is carried out on pbDb _ ToDateChar (); pbDb _ Get _ DynSequenceNo () sequence operation; sixthly, setting error codes of pbDb _ SetSQLCODE (); seventhly pbDb _ SetSQLMSG () wrong description setting.
8. The universal database driven adaptation interface system according to claim 1, further comprising the following database common function transformation universal interfaces: (1) PBDB _ NVL empty judgment; (2) PBDB _ TOUPPER size conversion; (3) PBDB _ TOUPPER lower case conversion; (4) splicing PBDB _ CONCAT fields; (5) removing left and right spaces from the PBDB _ TRIM field; (6) PBDB _ TOCHAR is converted into a character string; (7) PBDB _ SUM; (8) PBDB _ MAX takes the maximum value; (9) PBDB _ SUBSTR intercepts the character string; (10) the PBDB _ LENGTH character string takes LENGTH; (11) PBDB _ TODATE conversion date; (12) PBDB _ SYSDATE acquires a system date; (13) PBDB _ ADDDATE date of addition; (14) PBDB _ ADDMONTH increase month; (15) PBDB _ ROWNUM acquires a record line number; (16) PBDB _ TOHEX is converted to 16-ary.
9. The universal database driven adaptation interface system according to claim 1, wherein the universal database driven adaptation interface API is provided in the database application system through the static library libpbcomm.a and the dynamic library libpbcomm.so as to support a plurality of operating system versions of AIX/HP-UX/Linux, for the static library approach, by compiling and linking a library file to a target program, a corresponding API is directly called in the code; for the dynamic LIBRARY mode, the LIBRARY file is placed in the directory pointed by the environment variable LD _ LIBRARY _ PATH, and after the LIBRARY file is opened in the code in a dlopen () mode, the corresponding API is directly called.
10. The universal database driven adaptation interface system according to claim 1, wherein the universal database driven adaptation interface API is customized by the macro at pre-compilation time to support differences in support of different database table pairs: [1] controlling the LENGTH of an operation statement through the macro MAX _ SQLSTR _ LENGTH; [2] controlling the number of the inserted fields through a macro MAX _ INSERT _ ITEMS; [3] controlling the number of conditions through a macro MAX _ WHERE _ ITEMS; [4] controlling the number of the UPDATE fields through the macro MAX _ UPDATE _ ITEMS; [5] controlling the number of the query fields through a macro MAX _ SELECT _ ITEMS; [6] controlling the SIZE of the number of returned records of the single query through the macro FETCH _ SIZE; [7] the single field return record value size is controlled by the macro MAX _ value _ LENGTH.
11. The universal database driven adaptation interface system of claim 1 wherein the universal database driven adaptation interface comprises the following interfaces of developer custom statements: <1> custom INSERT statement interface INSERT _ stuct. <2> interface DELETE _ STRUCT. sDeleteSql of custom DELETE statement; <3> custom modification statement interface UPDATE _ STRUCT. sUpdateSql; sSelectSql, custom query statement interface SELECT _ STRUCT.
12. The universal database driver adaptation interface system according to claim 1, wherein the adaptation operation interface supports dynamic setting of added, deleted, modified, and checked fields and variable binding through a dynamic array to support differences caused by whether different database pairs are bound, and for a database that supports binding, the universal database driver adaptation interface automatically generates a binding statement according to the fields and conditions transferred after the developed calling interface, and returns the execution result to the user.
13. The universal database driven adaptation interface system according to claim 1, wherein the universal database driven adaptation interface comprises sequence support, by invoking different sequence fetching branches at environment variable SEQ _ MODE settings, by adding sequence cache to efficiently fetch sequences.
14. The universal database driven adaptation interface system according to claim 1, wherein the universal database driven adaptation interface comprises a monitoring module, and the monitoring module grasps the operation condition of the database driven adaptation interface through the log file of the universal database driven adaptation interface to locate and analyze the operation problem of the universal database driven adaptation interface.
CN202010920851.3A 2020-09-04 2020-09-04 General database drive adaptation interface system Pending CN112231374A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010920851.3A CN112231374A (en) 2020-09-04 2020-09-04 General database drive adaptation interface system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010920851.3A CN112231374A (en) 2020-09-04 2020-09-04 General database drive adaptation interface system

Publications (1)

Publication Number Publication Date
CN112231374A true CN112231374A (en) 2021-01-15

Family

ID=74115961

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010920851.3A Pending CN112231374A (en) 2020-09-04 2020-09-04 General database drive adaptation interface system

Country Status (1)

Country Link
CN (1) CN112231374A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113296747A (en) * 2021-07-27 2021-08-24 南京理控物联技术有限公司 Method for efficiently docking various mounting devices through software in intelligent lamp pole system
CN115994146A (en) * 2023-03-22 2023-04-21 烟台云朵软件有限公司 Hybrid data storage engine system, data storage method and access method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1448867A (en) * 2002-03-30 2003-10-15 深圳市中兴通讯股份有限公司 Method for accessing database system uniformly
CN103092970A (en) * 2013-01-24 2013-05-08 华为技术有限公司 Database operation method and device
CN105260403A (en) * 2015-09-22 2016-01-20 广东同望科技股份有限公司 Universal cross-database access method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1448867A (en) * 2002-03-30 2003-10-15 深圳市中兴通讯股份有限公司 Method for accessing database system uniformly
CN103092970A (en) * 2013-01-24 2013-05-08 华为技术有限公司 Database operation method and device
CN105260403A (en) * 2015-09-22 2016-01-20 广东同望科技股份有限公司 Universal cross-database access method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
强晓琳: "数据库统一接口设计与实现", 科学技术与工程, vol. 6, no. 11 *
蒋宗合, 常强林, 杨扬, 卞洪流, 骞晓东: "Linux下通用数据库访问接口及在宽带网络计费系统中的应用", 武警工程学院学报, no. 02 *
蹇洁;武建军;温平川;谢青;: "基于SOA的社区信息化基础数据库通用接口设计", 计算机工程与设计, no. 16 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113296747A (en) * 2021-07-27 2021-08-24 南京理控物联技术有限公司 Method for efficiently docking various mounting devices through software in intelligent lamp pole system
CN113296747B (en) * 2021-07-27 2021-10-15 南京理控物联技术有限公司 Method for efficiently docking various mounting devices through software in intelligent lamp pole system
CN115994146A (en) * 2023-03-22 2023-04-21 烟台云朵软件有限公司 Hybrid data storage engine system, data storage method and access method

Similar Documents

Publication Publication Date Title
US11354284B2 (en) System and method for migration of a legacy datastore
Templeton et al. Mermaid—A front-end to distributed heterogeneous databases
CN101499069B (en) Internal memory database file updating method and apparatus
US6278994B1 (en) Fully integrated architecture for user-defined search
US6163776A (en) System and method for exchanging data and commands between an object oriented system and relational system
US6339769B1 (en) Query optimization by transparently altering properties of relational tables using materialized views
CN105718593B (en) A kind of database inquiry optimization method and system
US7096231B2 (en) Export engine which builds relational database directly from object model
US8996458B2 (en) High volume, high speed adaptive data replication
CN112231374A (en) General database drive adaptation interface system
CN101645074A (en) Method for accessing relational databases of different types
US20030088546A1 (en) Collecting and/or presenting demographics information in a database system
US11704317B2 (en) Partial group by for eager group by placement query plans
JPH0667867A (en) Data base accessing system for application program
CN111125440A (en) Monad-based persistent layer composite condition query method and storage medium
CN101174222A (en) Data version upgrading method
US6618720B1 (en) Common spool files for maintaining join indexes
US6192358B1 (en) Multiple-stage evaluation of user-defined predicates
Bi Research and application of SQLite embedded database technology
JP3808941B2 (en) Parallel database system communication frequency reduction method
US10409815B2 (en) SQLScript compilation tracing system
Rowland et al. The 3B20D processor & DMERT operating system: Software development system
CN111241065A (en) Security multi-compatibility lightweight database adaptation development and operation device supporting domestic database
Kersten et al. The architecture of the PLAIN data base handler
Lu et al. SQL2FPGA: Automatic Acceleration of SQL Query Processing on Modern CPU-FPGA Platforms

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