WO2016206405A1 - Database accessing method and device - Google Patents

Database accessing method and device Download PDF

Info

Publication number
WO2016206405A1
WO2016206405A1 PCT/CN2016/075801 CN2016075801W WO2016206405A1 WO 2016206405 A1 WO2016206405 A1 WO 2016206405A1 CN 2016075801 W CN2016075801 W CN 2016075801W WO 2016206405 A1 WO2016206405 A1 WO 2016206405A1
Authority
WO
WIPO (PCT)
Prior art keywords
access
database
interface
application
target database
Prior art date
Application number
PCT/CN2016/075801
Other languages
French (fr)
Chinese (zh)
Inventor
杨兆辉
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016206405A1 publication Critical patent/WO2016206405A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • 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/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • 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/23Updating

Definitions

  • the present application relates to the field of data processing technologies, for example, to a database access method and apparatus.
  • the database system needs to be upgraded, for example, to access a new database in the database system, or to replace the original database
  • ensuring the integrity and stability of the database system is a major challenge to the upgrade operation.
  • the current practice is to add a new interface to the database system when the database system is added to the database system, or to replace the interface with the new database.
  • the database-adaptive interface is modified into an interface that is adapted to the replaced database, thereby completing the upgrade of the database system.
  • large-scale changes will be made to the database system, thereby destroying the integrity of the original system and laying a hidden danger for the stability of the system.
  • the database system originally only includes the database Sybase IQ, and the CPP (C++) application accesses Sybase IQ through the ODBC (Open Database Connectivity) interface.
  • Sybase IQ is a centralized storage columnar database.
  • ODBC Open Database Connectivity
  • centralized storage cannot meet the storage requirements of massive data, and a large data database Hive needs to be accessed in the database system.
  • accessing Hive using the ODBC interface is not stable, and accessing Hive using the JDBC (Java Data Base Connectivity) interface is relatively stable. Therefore, when the CPP application accesses the JDBC interface, it needs to add a CPP to call the transfer interface of the Java program.
  • JDBC Java Data Base Connectivity
  • the CPP application needs to access both the ODBC interface and the CPP to JDBC interface.
  • the calling methods of the two interfaces are inconsistent. Therefore, the CPP application needs to pay attention to some technical details of the interface layer, which makes the application layer access more and more complicated.
  • a database access method and device which can access each database in the database system independently of the interface layer of the database system, and shield the application from different accesses to different types of databases.
  • the database system is upgraded, the system can be guaranteed. Stability and integrity, and the application does not need to be aware, making application access simple.
  • a database access method includes: receiving an access request sent by an application to a target database in a database system; and selecting an access interface corresponding to the target database from an access interface corresponding to each type of database preset in the interface layer; The access request is invoked, and the selected access interface is invoked to perform an access operation on the target database.
  • a database accessing device comprising: a receiving module configured to receive an access request sent by an application to a target database in a database system; and a selecting module configured to be in an access interface corresponding to each type of database preset in the interface layer Selecting an access interface corresponding to the target database; the access module is configured to invoke the selected access interface to perform an access operation on the target database according to the access request.
  • the database access method and device when receiving an access request sent by the application to the target database in the database system, selecting the target from the access interfaces corresponding to the various types of databases preset in the interface layer An access interface corresponding to the database, and then invoking the selected access interface to perform an access operation on the target database according to the access request, so that each database in the database system can be accessed through an interface layer independent of the database system, and the application is shielded from different types of databases.
  • the difference in access when the database system is upgraded, can ensure the stability and integrity of the system, and the application does not need to be aware, thus simplifying the access of the application and reducing the workload of application development.
  • FIG. 1 is a diagram showing an example of accessing a database after a database system is upgraded in the related art
  • FIG. 2 is a flowchart of a database access method according to a first embodiment of the present invention
  • FIG. 3 is a diagram showing an application example of a database access method according to a first embodiment of the present invention
  • FIG. 4 is a flowchart of a database access method according to a third embodiment of the present invention.
  • FIG. 5 is a diagram showing an application example of a database access method according to a third embodiment of the present invention.
  • FIG. 6 is a block diagram of a database access apparatus according to a fourth embodiment of the present invention.
  • FIG. 2 it is a flowchart of a database access method according to a first embodiment of the present invention.
  • the method includes:
  • each database in the database system can be accessed through an interface layer independent of the database system, and the application layer can be shielded from different types of databases.
  • the database system is upgraded, the stability and integrity of the system can be ensured.
  • the application doesn't need to be aware, which simplifies application access and reduces the amount of application development effort.
  • the application described in S1 is, for example, a CPP program, a Java application, or the like.
  • the app is one of the applications in the application layer.
  • One or more applications included in the application layer can access each of the same kind or different kinds of databases in the database system through the interface layer.
  • the architecture of the application layer, interface layer and database system is shown in Figure 3.
  • the interface layer is set independently of the database system.
  • the interface layer is pre-configured with access interfaces corresponding to various types of databases.
  • the access interfaces corresponding to the various types of databases are preset and optimized according to the access characteristics of various databases, and can be flexibly updated according to requirements, for example, adding a certain type of database correspondingly. Access interface, or modify the access interface corresponding to a certain type of database.
  • the database system may include five types of databases: Hive, Impala, Spark SQL, Oracle, and Sybase IQ. According to the access characteristics of the five types of databases, the corresponding access interfaces may be preset as follows: :
  • the default Hive access interface is Hive JDBC.
  • the default Impala access interface is Impala JDBC
  • the default access interface of Spark SQL is Hive Context
  • the default Oracle access interface is Oracle ODBC.
  • the default Sybase IQ access interface is Sybase IQ ODBC.
  • the access request described in S1 may be, for example, a request for querying, saving, or analyzing data in the target database.
  • the access request may be sent to the interface layer when one or more programs in the application layer need to query or analyze data in the target database, or when data needs to be saved to the target database.
  • the target database to be accessed is obtained, so that the preset access interface corresponding to the target database is found out from the interface layer.
  • the identifier of the target database such as an ID number, may be obtained according to the access request, and the identifier is compared with the identifier of each database in the database system to find the target database.
  • the selected access interface is invoked to perform an access operation on the target database.
  • the selected access interface may be invoked in S3 to obtain an access result to the target database, and the access result is sent to the application.
  • the selected access interface is called to save the database to the target database, and the access result may be information that the data is saved successfully.
  • the selected access interface is invoked to query the data in the target database, and the data obtained by the query is used as the access result, and then the access result is obtained through the selected access interface. And send the result of the visit to the application.
  • the selected access interface is called to analyze the data in the target database, and the analysis result is used as an access result, and then the access result is obtained through the selected access interface, and The result of the visit is sent to the application, and so on.
  • the database access method provided by the embodiment of the present invention, the application layer and the database system interact indirectly through the interface layer independent of the database system, and can block the access difference of the application layer to different types of databases.
  • the database system is upgraded, for example, replacing Hive in Figure 3 with Impala, Spark SQL, or replacing Sybase IQ with Oracle, the application layer code does not need to be modified, so the application layer does not need to be aware, which not only makes the application layer access simple. It also ensures the stability and integrity of the system.
  • the second embodiment of the present invention provides a database access method, which is compared with the database access method provided by the first embodiment.
  • the access request sent by the receiving application to the target database in the database system in S1 can be implemented by a data exchange protocol independent of the programming language.
  • the programming language-independent data exchange protocol may be a Simple Object Access Protocol (SOAP) based on the HyperText Transfer Protocol (HTTP).
  • SOAP Simple Object Access Protocol
  • HTTP HyperText Transfer Protocol
  • the access result sent to the application through the selected access interface can also be implemented by the programming language independent data exchange protocol.
  • the application layer and the general interface layer implement interaction through the programming language-independent data exchange protocol, such as SOAP
  • the application layer application can be an application developed for any mainstream programming language, in accordance with an agreed-upon programming language.
  • SOAP accesses the database system, thus traversing the firewall across programming languages.
  • FIG. 4 it is a flowchart of a database access method according to a third embodiment of the present invention.
  • the database access methods described in the first embodiment and the second embodiment are applied to an application scenario in which a big data database (for example, Hive) is integrated with a legacy database (for example, Sybase IQ).
  • the application in the application layer can send a data analysis request to the Hive through the interface layer.
  • the Hive returns the analysis result to the application layer.
  • the application sends a data save request to Sybase IQ through the interface layer.
  • Sybase IQ saves the analysis result.
  • the application has the same data analysis request, you can directly access Sybase IQ and obtain the analysis result from Sybase IQ.
  • An example of the application layer, interface layer, and Hive and Sybase IQ architecture is shown in Figure 5.
  • S12 Select a Hive JDBC interface corresponding to the Hive from the access interfaces corresponding to the various types of databases preset in the interface layer.
  • the Hive and Sybase IQ databases are integrated in the database system.
  • the access interfaces of the two databases are different, namely the Hive JDBC interface and the Sybase IQ ODBC interface.
  • the application can extract data from Hive and store it in Sybase IQ.
  • the indirect interaction between the application and the database system through the interface layer can shield the application layer from different types of database access differences.
  • a common database access channel is used for the application layer.
  • a fourth embodiment of the present invention provides a database access apparatus 100, which includes a receiving module 101, a selecting module 102, and an access module 103.
  • the database access device 100 can be embedded or peripheral to the interface layer. It will be understood that each of the above modules may refer to a computer program or program segment configured to perform one or more specific functions. Moreover, the distinction between the above modules does not mean that the actual program code is also separate.
  • the receiving module 101 is configured to receive an access request sent by the application to the target database in the database system.
  • the receiving module 101 can implement an access request sent by the application to the target database in the database system through a data exchange protocol independent of the programming language.
  • the programming language independent data exchange protocol may be a Simple Object Access Protocol (SOAP).
  • the selecting module 102 is configured to select an access interface corresponding to the target database from the access interfaces corresponding to the various types of databases preset in the interface layer.
  • the access module 103 is configured to invoke the selected access interface to perform an access operation on the target database according to the access request.
  • the access module 103 can also send the access result to the application via the selected access interface.
  • the database access device 100 can access the databases in the database system independently of the interface layer of the database system, and shield the application from different accesses to different types of databases.
  • the stability of the system can be ensured. Integrity, and the application layer does not need to be aware, thus simplifying access at the application layer.
  • the application layer and the general interface layer pass the programming language-independent data exchange protocol, the application layer application can be an application developed for any mainstream programming language, and accesses the database according to an agreed protocol in any programming language. The system thus spans the programming language and traverses the firewall.
  • an embodiment of the present invention further provides a computer readable storage medium having stored therein computer executable instructions, such as a non-volatile memory such as an optical disk, a hard disk, or a flash memory.
  • computer executable instructions may cause a computer or similar computing device to perform various operations in the database access method described above.
  • the present application discloses a database access method, which includes: receiving an access request sent by an application to a target database in a database system; and selecting an access interface corresponding to the target database from an access interface corresponding to each type of database preset in the interface layer. And invoking the selected access interface to perform an access operation on the target database according to the access request.
  • the application also discloses a database access device. The method and apparatus can simplify application access and ensure stability and integrity of the database system upgrade.

Abstract

Disclosed is a database accessing method, comprising: receiving an access request transmitted by an application program and for a target database in a database system; selecting, from access interfaces corresponding to various databases and preset in an interface layer, an access interface corresponding to the target database; and invoking, according to the access request, the selected access interface to access the target database. Also disclosed is a database accessing device. The method and the device simplify access of an application program, and ensure stability and integrality of a database system when being upgraded.

Description

一种数据库访问方法及装置Database access method and device 技术领域Technical field
本申请涉及数据处理技术领域,例如涉及一种数据库访问方法及装置。The present application relates to the field of data processing technologies, for example, to a database access method and apparatus.
背景技术Background technique
在通信、互联网、计算机等领域,随着处理的数据量与日俱增,目前大数据数据库已经得到广泛的使用。从Oracle、SybaseIQ到Hive、Spark,越来越多的数据库被应用在数据库系统中,成为数据库系统中非常重要的一个部分,为各类数据提供了保存、查询、分析等访问方式。In the fields of communication, Internet, computer, etc., with the increasing amount of data processed, big data databases have been widely used. From Oracle, SybaseIQ to Hive, Spark, more and more databases are being applied in the database system, becoming a very important part of the database system, providing storage, query, analysis and other access methods for various types of data.
当数据库系统需要升级,例如在数据库系统中接入新的数据库,或是替换原有的数据库时,保证数据库系统的完整性和稳定性是对升级操作提出的一大挑战。为了使数据库系统能够兼容不同种类的数据库,目前的做法是当在数据库系统中新增一种数据库时,需要在数据库系统中新增一套与新增数据库适配的接口,或将与替换前的数据库适配的接口修改成与替换后的数据库适配的接口,从而完成数据库系统的升级。这样不可避免地会对数据库系统进行大规模的改动,从而破坏了原有系统的完整性,为系统的稳定性埋下了隐患。When the database system needs to be upgraded, for example, to access a new database in the database system, or to replace the original database, ensuring the integrity and stability of the database system is a major challenge to the upgrade operation. In order to make the database system compatible with different kinds of databases, the current practice is to add a new interface to the database system when the database system is added to the database system, or to replace the interface with the new database. The database-adaptive interface is modified into an interface that is adapted to the replaced database, thereby completing the upgrade of the database system. Inevitably, large-scale changes will be made to the database system, thereby destroying the integrity of the original system and laying a hidden danger for the stability of the system.
例如图1所示,数据库系统中原先仅包括数据库Sybase IQ,CPP(C++)应用程序通过ODBC(Open Database Connectivity,开放数据库互连)接口访问Sybase IQ。Sybase IQ是一种集中存储的列式数据库。随着数据量越来越大,集中存储无法满足海量数据的存储需求,需要在数据库系统中接入一大数据数据库Hive。然而采用ODBC接口访问Hive不太稳定,而采用JDBC(Java Data Base Connectivity,Java数据库互连)接口访问Hive是比较稳定的。因此,CPP应用程序访问JDBC接口时需要增加一个CPP调用Java程序的转接接口。CPP应用程序既需要访问ODBC接口,也需要访问CPP转JDBC接口,而这两种接口的调用方式不一致,因此CPP应用程序需要关注接口层的一些技术细节,导致应用层访问越来越复杂。For example, as shown in Figure 1, the database system originally only includes the database Sybase IQ, and the CPP (C++) application accesses Sybase IQ through the ODBC (Open Database Connectivity) interface. Sybase IQ is a centralized storage columnar database. As the amount of data increases, centralized storage cannot meet the storage requirements of massive data, and a large data database Hive needs to be accessed in the database system. However, accessing Hive using the ODBC interface is not stable, and accessing Hive using the JDBC (Java Data Base Connectivity) interface is relatively stable. Therefore, when the CPP application accesses the JDBC interface, it needs to add a CPP to call the transfer interface of the Java program. The CPP application needs to access both the ODBC interface and the CPP to JDBC interface. The calling methods of the two interfaces are inconsistent. Therefore, the CPP application needs to pay attention to some technical details of the interface layer, which makes the application layer access more and more complicated.
发明内容 Summary of the invention
有鉴于此,提供一种数据库访问方法及装置,可以通过独立于数据库系统的接口层访问数据库系统中各数据库,屏蔽应用程序对不同种类数据库的访问差异,在数据库系统升级时,可以保证系统的稳定性和完整性,且应用程序无需感知,从而使应用程序的访问简单化。In view of the above, a database access method and device are provided, which can access each database in the database system independently of the interface layer of the database system, and shield the application from different accesses to different types of databases. When the database system is upgraded, the system can be guaranteed. Stability and integrity, and the application does not need to be aware, making application access simple.
一种数据库访问方法,包括:接收应用程序发送的对数据库系统中目标数据库的访问请求;从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口;根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。A database access method includes: receiving an access request sent by an application to a target database in a database system; and selecting an access interface corresponding to the target database from an access interface corresponding to each type of database preset in the interface layer; The access request is invoked, and the selected access interface is invoked to perform an access operation on the target database.
一种数据库访问装置,包括:接收模块,被配置为接收应用程序发送的对数据库系统中目标数据库的访问请求;选择模块,被配置为从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口;访问模块,被配置为根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。A database accessing device, comprising: a receiving module configured to receive an access request sent by an application to a target database in a database system; and a selecting module configured to be in an access interface corresponding to each type of database preset in the interface layer Selecting an access interface corresponding to the target database; the access module is configured to invoke the selected access interface to perform an access operation on the target database according to the access request.
上述技术方案的有益效果是:数据库访问方法及装置,在接收到应用程序发送的对数据库系统中目标数据库的访问请求时,从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口,然后根据所述访问请求调用所选择的访问接口对该目标数据库执行访问操作,因此可以通过独立于数据库系统的接口层访问数据库系统中各数据库,屏蔽应用程序对不同种类数据库的访问差异,在数据库系统升级时,可以保证系统的稳定性和完整性,且应用程序无需感知,从而使应用程序的访问简单化,减轻应用程序开发的工作量。The beneficial effects of the foregoing technical solution are: the database access method and device, when receiving an access request sent by the application to the target database in the database system, selecting the target from the access interfaces corresponding to the various types of databases preset in the interface layer An access interface corresponding to the database, and then invoking the selected access interface to perform an access operation on the target database according to the access request, so that each database in the database system can be accessed through an interface layer independent of the database system, and the application is shielded from different types of databases. The difference in access, when the database system is upgraded, can ensure the stability and integrity of the system, and the application does not need to be aware, thus simplifying the access of the application and reducing the workload of application development.
附图概述BRIEF abstract
图1为相关技术中数据库系统升级后对数据库的访问方式的示例图;FIG. 1 is a diagram showing an example of accessing a database after a database system is upgraded in the related art;
图2为本发明第一实施例提供的数据库访问方法的流程图;2 is a flowchart of a database access method according to a first embodiment of the present invention;
图3为本发明第一实施例提供的数据库访问方法的应用示例图;FIG. 3 is a diagram showing an application example of a database access method according to a first embodiment of the present invention; FIG.
图4为本发明第三实施例提供的数据库访问方法的流程图;4 is a flowchart of a database access method according to a third embodiment of the present invention;
图5为本发明第三实施例提供的数据库访问方法的应用示例图; FIG. 5 is a diagram showing an application example of a database access method according to a third embodiment of the present invention; FIG.
图6为本发明第四实施例提供的数据库访问装置的框图。FIG. 6 is a block diagram of a database access apparatus according to a fourth embodiment of the present invention.
本发明的实施方式Embodiments of the invention
为阐述本发明的技术方案及技术效果,以下结合附图及实施例,对依据本发明的实施方式、结构、特征及其技术效果,详细说明如后。In order to explain the technical solutions and technical effects of the present invention, the embodiments, structures, features and technical effects according to the present invention will be described in detail below with reference to the accompanying drawings and embodiments.
第一实施例First embodiment
参阅图2所示,为本发明第一实施例提供的数据库访问方法的流程图。在本实施例中,该方法包括:Referring to FIG. 2, it is a flowchart of a database access method according to a first embodiment of the present invention. In this embodiment, the method includes:
S1,接收应用程序发送的对数据库系统中目标数据库的访问请求;S1, receiving an access request sent by the application to the target database in the database system;
S2,从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口;S2, selecting an access interface corresponding to the target database from an access interface corresponding to each type of database preset in the interface layer;
S3,根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。S3. In response to the access request, invoke the selected access interface to perform an access operation on the target database.
按照上述的数据库访问方法,可以通过独立于数据库系统的接口层访问数据库系统中各数据库,屏蔽应用层对不同种类数据库的访问差异,在数据库系统升级时,可以保证系统的稳定性和完整性,且应用程序无需感知,从而使应用程序的访问简单化,减轻应用程序开发的工作量。According to the database access method described above, each database in the database system can be accessed through an interface layer independent of the database system, and the application layer can be shielded from different types of databases. When the database system is upgraded, the stability and integrity of the system can be ensured. And the application doesn't need to be aware, which simplifies application access and reduces the amount of application development effort.
在一些实例中,上述方法的实现细节如下:In some instances, the implementation details of the above method are as follows:
S1中所述的应用程序例如为CPP程序、Java应用程序等。该应用程序为应用层中的应用程序之一。该应用层中包括的一个或多个应用程序可以通过所述接口层访问数据库系统中的各个相同种类或不同种类的数据库。其中,该应用层、接口层及数据库系统的架构如图3所示。The application described in S1 is, for example, a CPP program, a Java application, or the like. The app is one of the applications in the application layer. One or more applications included in the application layer can access each of the same kind or different kinds of databases in the database system through the interface layer. The architecture of the application layer, interface layer and database system is shown in Figure 3.
所述接口层独立于所述数据库系统设置。该接口层中预设有各类数据库对应的访问接口,该各类数据库对应的访问接口根据各类数据库的访问特性预设和优化,并且可以根据需要灵活地更新,例如新增某类数据库对应的访问接口,或修改某类数据库对应的访问接口。在一些实例中,如图3所示,数据库系统中可以包括Hive、Impala、Spark SQL、Oracle和Sybase IQ五类数据库,根据该五类数据库的访问特性,可以将其对应的访问接口预设如下: The interface layer is set independently of the database system. The interface layer is pre-configured with access interfaces corresponding to various types of databases. The access interfaces corresponding to the various types of databases are preset and optimized according to the access characteristics of various databases, and can be flexibly updated according to requirements, for example, adding a certain type of database correspondingly. Access interface, or modify the access interface corresponding to a certain type of database. In some examples, as shown in FIG. 3, the database system may include five types of databases: Hive, Impala, Spark SQL, Oracle, and Sybase IQ. According to the access characteristics of the five types of databases, the corresponding access interfaces may be preset as follows: :
预设Hive的访问接口为Hive JDBC;The default Hive access interface is Hive JDBC.
预设Impala的访问接口为Impala JDBC;The default Impala access interface is Impala JDBC;
预设Spark SQL的访问接口为Hive Context;The default access interface of Spark SQL is Hive Context;
预设Oracle的访问接口为Oracle ODBC;及The default Oracle access interface is Oracle ODBC; and
预设Sybase IQ的访问接口为Sybase IQ ODBC。The default Sybase IQ access interface is Sybase IQ ODBC.
S1中所述的访问请求例如可以是对目标数据库中数据的查询、保存或分析等请求。当应用层中的一个或多个程序需要查询或分析目标数据库中的数据时,或需要将数据保存至目标数据库时,可向接口层发送所述访问请求。The access request described in S1 may be, for example, a request for querying, saving, or analyzing data in the target database. The access request may be sent to the interface layer when one or more programs in the application layer need to query or analyze data in the target database, or when data needs to be saved to the target database.
S2中根据所述的访问请求,得知所需访问的目标数据库,从而从接口层中找出预设的该目标数据库对应的访问接口。可以根据所述访问请求获取目标数据库的标识,例如ID号等,并将该标识与数据库系统中各个数据库的标识进行比对,从而找出目标数据库。In S2, according to the access request, the target database to be accessed is obtained, so that the preset access interface corresponding to the target database is found out from the interface layer. The identifier of the target database, such as an ID number, may be obtained according to the access request, and the identifier is compared with the identifier of each database in the database system to find the target database.
S3中根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。此外,S3中还可以调用所选择的访问接口获取对目标数据库的访问结果,并将该访问结果发送至所述应用程序。例如,若该访问请求为请求将数据保存到目标数据库中,则调用所选择的访问接口将该数据库保存至目标数据库,所述访问结果可以为该数据保存成功的信息。若该访问请求为请求查询目标数据库中的数据,则调用所选择的访问接口在目标数据库中查询该数据,并将查询得到的该数据作为访问结果,然后通过所选择的访问接口获取该访问结果,并将该访问结果发送至所述应用程序。若该访问请求为请求分析目标数据库中的数据,则调用所选择的访问接口在目标数据库中分析该数据,并将分析结果作为访问结果,然后通过所选择的访问接口获取该访问结果,并将该访问结果发送至所述应用程序,等等。In S3, according to the access request, the selected access interface is invoked to perform an access operation on the target database. In addition, the selected access interface may be invoked in S3 to obtain an access result to the target database, and the access result is sent to the application. For example, if the access request saves the data to the target database for the request, the selected access interface is called to save the database to the target database, and the access result may be information that the data is saved successfully. If the access request is to query the data in the target database, the selected access interface is invoked to query the data in the target database, and the data obtained by the query is used as the access result, and then the access result is obtained through the selected access interface. And send the result of the visit to the application. If the access request is to request analysis of data in the target database, the selected access interface is called to analyze the data in the target database, and the analysis result is used as an access result, and then the access result is obtained through the selected access interface, and The result of the visit is sent to the application, and so on.
综上所述,通过本发明实施例提供的数据库访问方法,应用层与数据库系统通过独立于数据库系统的接口层间接进行交互,可以屏蔽应用层对不同种类数据库的访问差异。在数据库系统升级时,例如将图3中的Hive替换为Impala、Spark SQL,或将Sybase IQ替换为Oracle时,应用层的代码不需要修改,从而应用层无需感知,不仅使应用层的访问简单化,还可以保证系统的稳定性和完整性。 In summary, the database access method provided by the embodiment of the present invention, the application layer and the database system interact indirectly through the interface layer independent of the database system, and can block the access difference of the application layer to different types of databases. When the database system is upgraded, for example, replacing Hive in Figure 3 with Impala, Spark SQL, or replacing Sybase IQ with Oracle, the application layer code does not need to be modified, so the application layer does not need to be aware, which not only makes the application layer access simple. It also ensures the stability and integrity of the system.
第二实施例Second embodiment
本发明第二实施例提供一种数据库访问方法,其相较于第一实施例提供的数据库访问方法,提出:The second embodiment of the present invention provides a database access method, which is compared with the database access method provided by the first embodiment.
S1中接收应用程序发送的对数据库系统中目标数据库的访问请求可通过与编程语言无关的数据交换协议实现。该与编程语言无关的数据交换协议可以为基于超文本传输协议(HTTP,HyperText Transfer Protocol)的简单对象访问协议(SOAP,Simple Object Access Protoco)。同样的,所述访问结果通过所选择的访问接口发送至应用程序也可通过所述与编程语言无关的数据交换协议实现。The access request sent by the receiving application to the target database in the database system in S1 can be implemented by a data exchange protocol independent of the programming language. The programming language-independent data exchange protocol may be a Simple Object Access Protocol (SOAP) based on the HyperText Transfer Protocol (HTTP). Similarly, the access result sent to the application through the selected access interface can also be implemented by the programming language independent data exchange protocol.
由于应用层与通用接口层通过所述与编程语言无关的数据交换协议,例如SOAP实现交互,因此应用层的应用程序可以为任何主流编程语言开发的应用程序,以任意一种编程语言按照约定的SOAP访问数据库系统,从而跨越编程语言,穿越防火墙。Since the application layer and the general interface layer implement interaction through the programming language-independent data exchange protocol, such as SOAP, the application layer application can be an application developed for any mainstream programming language, in accordance with an agreed-upon programming language. SOAP accesses the database system, thus traversing the firewall across programming languages.
第三实施例Third embodiment
参阅图4所示,为本发明第三实施例提供的数据库访问方法的流程图。在本实施例中,将第一实施例和第二实施例所述的数据库访问方法应用于一种大数据数据库(例如Hive)与传统数据库(例如Sybase IQ)整合的应用场景。应用层中的应用程序可以通过接口层向Hive下发数据分析请求,Hive接收到该数据分析请求后,将分析结果返回给应用层。应用程序在接收到该分析结果后,通过接口层向Sybase IQ下发数据保存请求,Sybase IQ接收到该数据保存请求后,保存该分析结果。此外,若应用程序再有相同的所述数据分析请求,可以直接访问Sybase IQ,从Sybase IQ中获取所述分析结果。其中,应用层、接口层与Hive和Sybase IQ的架构示例如图5所示。Referring to FIG. 4, it is a flowchart of a database access method according to a third embodiment of the present invention. In this embodiment, the database access methods described in the first embodiment and the second embodiment are applied to an application scenario in which a big data database (for example, Hive) is integrated with a legacy database (for example, Sybase IQ). The application in the application layer can send a data analysis request to the Hive through the interface layer. After receiving the data analysis request, the Hive returns the analysis result to the application layer. After receiving the analysis result, the application sends a data save request to Sybase IQ through the interface layer. After receiving the data save request, Sybase IQ saves the analysis result. In addition, if the application has the same data analysis request, you can directly access Sybase IQ and obtain the analysis result from Sybase IQ. An example of the application layer, interface layer, and Hive and Sybase IQ architecture is shown in Figure 5.
本实施例提供的数据库访问方法可以包括:The database access method provided in this embodiment may include:
S11,通过SOAP接收应用程序发送的对数据库系统中Hive的数据分析请求;此时,应用程序作为SOAP客户端,接口层作为SOAP服务端;S11, receiving, by the SOAP, the data analysis request sent by the application to the Hive in the database system; at this time, the application functions as a SOAP client, and the interface layer functions as a SOAP server;
S12,从接口层中预设的各类数据库对应的访问接口中选择Hive对应的Hive JDBC接口;S12: Select a Hive JDBC interface corresponding to the Hive from the access interfaces corresponding to the various types of databases preset in the interface layer.
S13,根据该数据分析请求,通过该Hive JDBC接口对Hive进行数据分析, 通过Hive JDBC接口得到分析结果,并将该分析结果返回至应用程序;S13. Perform data analysis on the Hive through the Hive JDBC interface according to the data analysis request. The analysis result is obtained through the Hive JDBC interface, and the analysis result is returned to the application;
S14,通过SOAP接收应用程序发送的将所述分析结果保存至数据库系统中Sybase IQ的数据保存请求;S14, the data saving request sent by the SOAP receiving application to save the analysis result to Sybase IQ in the database system;
S15,从接口层中预设的各类数据库对应的访问接口中选择Sybase IQ对应的Sybase IQ ODBC接口;S15, selecting a Sybase IQ ODBC interface corresponding to Sybase IQ from an access interface corresponding to each type of database preset in the interface layer;
S16,根据该数据保存请求,通过该Sybase IQ ODBC接口将所述分析结果保存至Sybase IQ,之后将分析结果持久化到Sybase IQ。S16, according to the data save request, save the analysis result to Sybase IQ through the Sybase IQ ODBC interface, and then persist the analysis result to Sybase IQ.
在本实施例中,数据库系统中整合有Hive和Sybase IQ两种数据库,这两种数据库对应的访问接口不同,分别为Hive JDBC接口和Sybase IQ ODBC接口。然而,通过将该Hive JDBC接口和Sybase IQ ODBC接口统一预设在独立的接口层中,应用程序可以从Hive中提取数据并存放到Sybase IQ中。应用程序与数据库系统之间通过接口层间接进行交互,从而可以屏蔽应用层对不同种类数据库的访问差异。对应用层而言,所使用的是一种通用的数据库访问通道。In this embodiment, the Hive and Sybase IQ databases are integrated in the database system. The access interfaces of the two databases are different, namely the Hive JDBC interface and the Sybase IQ ODBC interface. However, by presetting the Hive JDBC interface and the Sybase IQ ODBC interface to a separate interface layer, the application can extract data from Hive and store it in Sybase IQ. The indirect interaction between the application and the database system through the interface layer can shield the application layer from different types of database access differences. For the application layer, a common database access channel is used.
第四实施例Fourth embodiment
参阅图6所示,本发明第四实施例提供一种数据库访问装置100,其包括接收模块101、选择模块102和访问模块103。该数据库访问装置100可以嵌入或外设于所述的接口层。可以理解,上述的各模块可以是指计算机程序或者程序段,被配置为执行某一项或多项特定的功能。此外,上述各模块的区分并不代表实际的程序代码也是分开的。Referring to FIG. 6, a fourth embodiment of the present invention provides a database access apparatus 100, which includes a receiving module 101, a selecting module 102, and an access module 103. The database access device 100 can be embedded or peripheral to the interface layer. It will be understood that each of the above modules may refer to a computer program or program segment configured to perform one or more specific functions. Moreover, the distinction between the above modules does not mean that the actual program code is also separate.
接收模块101,被配置为接收应用程序发送的对数据库系统中目标数据库的访问请求。所述接收模块101可以通过与编程语言无关的数据交换协议实现接收应用程序发送的对数据库系统中目标数据库的访问请求。所述与编程语言无关的数据交换协议可以为简单对象访问协议(SOAP)。The receiving module 101 is configured to receive an access request sent by the application to the target database in the database system. The receiving module 101 can implement an access request sent by the application to the target database in the database system through a data exchange protocol independent of the programming language. The programming language independent data exchange protocol may be a Simple Object Access Protocol (SOAP).
选择模块102,被配置为从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口。The selecting module 102 is configured to select an access interface corresponding to the target database from the access interfaces corresponding to the various types of databases preset in the interface layer.
访问模块103,被配置为根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。所述访问模块103还可以将访问结果通过所选择的访问接口发送至所述应用程序。The access module 103 is configured to invoke the selected access interface to perform an access operation on the target database according to the access request. The access module 103 can also send the access result to the application via the selected access interface.
上述模块的实施细节可参考本发明第一实施例和第二实施例提供的数据库 访问方法中的描述,此处不再赘述。For details of implementation of the above modules, reference may be made to the databases provided by the first embodiment and the second embodiment of the present invention. The description in the access method is not described here.
本实施例提供的数据库访问装置100,可以通过独立于数据库系统的接口层访问数据库系统中各数据库,屏蔽应用程序对不同种类数据库的访问差异,在数据库系统升级时,可以保证系统的稳定性和完整性,且应用层无需感知,从而使应用层的访问简单化。此外,由于应用层与通用接口层通过所述与编程语言无关的数据交换协议,因此应用层的应用程序可以为任何主流编程语言开发的应用程序,以任意一种编程语言按照约定的协议访问数据库系统,从而跨越编程语言,穿越防火墙。The database access device 100 provided in this embodiment can access the databases in the database system independently of the interface layer of the database system, and shield the application from different accesses to different types of databases. When the database system is upgraded, the stability of the system can be ensured. Integrity, and the application layer does not need to be aware, thus simplifying access at the application layer. In addition, since the application layer and the general interface layer pass the programming language-independent data exchange protocol, the application layer application can be an application developed for any mainstream programming language, and accesses the database according to an agreed protocol in any programming language. The system thus spans the programming language and traverses the firewall.
此外,本发明实施例还提供一种计算机可读存储介质,其内存储有计算机可执行指令,上述的计算机可读存储介质例如为非易失性存储器例如光盘、硬盘、或者闪存。上述的计算机可执行指令可以使计算机或者类似的运算装置完成上述的数据库访问方法中的各种操作。In addition, an embodiment of the present invention further provides a computer readable storage medium having stored therein computer executable instructions, such as a non-volatile memory such as an optical disk, a hard disk, or a flash memory. The above computer executable instructions may cause a computer or similar computing device to perform various operations in the database access method described above.
以上所述,仅是本发明的实施例而已,并非对本发明作任何形式上的限制,虽然本发明已以实施例揭示如上,然而并非用以限定本发明,任何本领域技术人员,在不脱离本发明技术方案范围内,当可利用上述揭示的技术内容做出些许更动或修饰为等同变化的等效实施例,但凡是未脱离本发明技术方案内容,依据本发明实施例的技术实质对以上实施例所作的任何简介修改、等同变化与修饰,均仍属于本发明技术方案的范围内。The above is only an embodiment of the present invention, and is not intended to limit the scope of the present invention. The present invention has been disclosed by the embodiments, but is not intended to limit the present invention, and any person skilled in the art In the scope of the technical solutions of the present invention, the equivalents of the embodiments of the present invention may be made without departing from the technical scope of the present invention. Any of the brief modifications, equivalent changes and modifications made by the above embodiments are still within the scope of the technical solutions of the present invention.
工业实用性Industrial applicability
本申请公开了一种数据库访问方法,包括:接收应用程序发送的对数据库系统中目标数据库的访问请求;从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口;根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。本申请还公开了一种数据库访问装置。所述方法和装置可以使应用程序的访问简单化,保证数据库系统升级时的稳定性和完整性。 The present application discloses a database access method, which includes: receiving an access request sent by an application to a target database in a database system; and selecting an access interface corresponding to the target database from an access interface corresponding to each type of database preset in the interface layer. And invoking the selected access interface to perform an access operation on the target database according to the access request. The application also discloses a database access device. The method and apparatus can simplify application access and ensure stability and integrity of the database system upgrade.

Claims (10)

  1. 一种数据库访问方法,包括:A database access method, including:
    接收应用程序发送的对数据库系统中目标数据库的访问请求;Receiving an access request sent by the application to the target database in the database system;
    从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口;Selecting an access interface corresponding to the target database from the access interfaces corresponding to the various types of databases preset in the interface layer;
    根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。According to the access request, the selected access interface is invoked to perform an access operation on the target database.
  2. 如权利要求1所述的方法,其中,所述接收应用程序发送的对数据库系统中目标数据库的访问请求是通过与编程语言无关的数据交换协议实现的。The method of claim 1 wherein said receiving application sends an access request to a target database in a database system via a data exchange protocol independent of a programming language.
  3. 如权利要求2所述的方法,其中,所述与编程语言无关的数据交换协议为简单对象访问协议。The method of claim 2 wherein said programming language independent data exchange protocol is a simple object access protocol.
  4. 如权利要求1所述的方法,还包括:The method of claim 1 further comprising:
    调用所选择的访问接口获取对目标数据库的访问结果,并将该访问结果发送至所述应用程序。The selected access interface is invoked to obtain an access result to the target database, and the access result is sent to the application.
  5. 如权利要求4所述的方法,其中,所述访问结果通过所选择的访问接口发送至应用程序是通过与编程语言无关的数据交换协议实现的。The method of claim 4 wherein said accessing results are sent to the application via the selected access interface by a data exchange protocol independent of the programming language.
  6. 一种数据库访问装置,包括:A database access device comprising:
    接收模块,被配置为接收应用程序发送的对数据库系统中目标数据库的访问请求;a receiving module configured to receive an access request sent by an application to a target database in a database system;
    选择模块,被配置为从接口层中预设的各类数据库对应的访问接口中选择该目标数据库对应的访问接口;The selection module is configured to select an access interface corresponding to the target database from the access interfaces corresponding to the various types of databases preset in the interface layer;
    访问模块,被配置为根据所述访问请求,调用所选择的访问接口对该目标数据库执行访问操作。The access module is configured to invoke the selected access interface to perform an access operation on the target database according to the access request.
  7. 如权利要求6所述的装置,其中,所述接收模块,被配置为通过与编程 语言无关的数据交换协议接收应用程序发送的对数据库系统中目标数据库的访问请求。The apparatus of claim 6, wherein the receiving module is configured to pass and program The language-independent data exchange protocol receives an access request from the application to the target database in the database system.
  8. 如权利要求7所述的装置,其中,所述与编程语言无关的数据交换协议为简单对象访问协议。The apparatus of claim 7, wherein the programming language independent data exchange protocol is a simple object access protocol.
  9. 如权利要求6所述的装置,其中,所述访问模块还被配置为:The apparatus of claim 6 wherein said access module is further configured to:
    调用所选择的访问接口获取对目标数据库的访问结果,并将该访问结果发送至所述应用程序。The selected access interface is invoked to obtain an access result to the target database, and the access result is sent to the application.
  10. 如权利要求9所述的装置,其中,所述访问模块还被配置为:The apparatus of claim 9 wherein said access module is further configured to:
    通过与编程语言无关的数据交换协议将所述访问结果通过所选择的访问接口发送至应用程序。 The access result is sent to the application via the selected access interface via a data exchange protocol independent of the programming language.
PCT/CN2016/075801 2015-06-26 2016-03-07 Database accessing method and device WO2016206405A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510361770.3 2015-06-26
CN201510361770.3A CN106326256A (en) 2015-06-26 2015-06-26 Database access method and device

Publications (1)

Publication Number Publication Date
WO2016206405A1 true WO2016206405A1 (en) 2016-12-29

Family

ID=57586100

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/075801 WO2016206405A1 (en) 2015-06-26 2016-03-07 Database accessing method and device

Country Status (2)

Country Link
CN (1) CN106326256A (en)
WO (1) WO2016206405A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307122A (en) * 2020-10-30 2021-02-02 杭州海康威视数字技术股份有限公司 Data lake-based data management system and method

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108804087B (en) * 2017-04-26 2022-06-21 武汉斗鱼网络科技有限公司 Implementation method and implementation device for dynamically switching third-party program library

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101739460A (en) * 2009-12-16 2010-06-16 中国科学院对地观测与数字地球科学中心 Grid-based spatial data source unification service system and method
CN102314375A (en) * 2011-03-18 2012-01-11 北京神州数码思特奇信息技术股份有限公司 Heterogeneous database storage unified interface and database access method
US8745040B2 (en) * 2011-06-27 2014-06-03 Bmc Software, Inc. Service context
CN103902286A (en) * 2014-03-12 2014-07-02 郑州轻工业学院 Hierarchy type multi-source data fusion method based on SOA

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101661494B (en) * 2009-09-29 2012-06-20 莱芜钢铁集团有限公司 Data interactive method for distributed middleware and database

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101739460A (en) * 2009-12-16 2010-06-16 中国科学院对地观测与数字地球科学中心 Grid-based spatial data source unification service system and method
CN102314375A (en) * 2011-03-18 2012-01-11 北京神州数码思特奇信息技术股份有限公司 Heterogeneous database storage unified interface and database access method
US8745040B2 (en) * 2011-06-27 2014-06-03 Bmc Software, Inc. Service context
CN103902286A (en) * 2014-03-12 2014-07-02 郑州轻工业学院 Hierarchy type multi-source data fusion method based on SOA

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112307122A (en) * 2020-10-30 2021-02-02 杭州海康威视数字技术股份有限公司 Data lake-based data management system and method
CN112307122B (en) * 2020-10-30 2023-06-02 杭州海康威视数字技术股份有限公司 Data lake-based data management system and method

Also Published As

Publication number Publication date
CN106326256A (en) 2017-01-11

Similar Documents

Publication Publication Date Title
JP7271734B2 (en) Data serialization in distributed event processing systems
US11886429B2 (en) Persistent metadata catalog
US10079905B2 (en) Cross domain in-browser proxy
US7580946B2 (en) Smart integration engine and metadata-oriented architecture for automatic EII and business integration
US10291704B2 (en) Networked solutions integration using a cloud business object broker
US9552387B2 (en) Security for debugging of database sessions
US20150234884A1 (en) System and Method Involving Resource Description Framework Distributed Database Management System and/or Related Aspects
US9231974B2 (en) Dynamic policy-based entitlements from external data repositories
US20080208806A1 (en) Techniques for a web services data access layer
US20150006730A1 (en) Enabling multi-tenant virtual servers in a cloud system
US20170076012A1 (en) Processing log files using a database system
WO2020010702A1 (en) Log search method and system, computer device, and storage medium
US9515948B2 (en) Techniques for generically accessing data
CN101727475B (en) Method, device and system for acquiring database access process
WO2019242132A1 (en) Information filtering method and apparatus, computer device and storage medium
US9774652B2 (en) Systems to provide database updates
US20190102477A1 (en) Novel metadata relationships in a configuration management database
WO2016206405A1 (en) Database accessing method and device
US10846419B2 (en) Service for users to voluntarily self-identify in over the top (OTT) messaging
AU2017351024B2 (en) Processing application programming interface (API) queries based on variable schemas
US20230055129A1 (en) Techniques for utilizing patterns and logical entities
EP3462341B1 (en) Local identifiers for database objects
US11347768B2 (en) Parallel data synchronization of hierarchical data
US20120084795A1 (en) Model, service and implementation separation
US20230208715A1 (en) Optimizing network transactions for databases hosted on a public cloud

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16813521

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16813521

Country of ref document: EP

Kind code of ref document: A1