Data source access method and device, equipment, storage medium and program product

By single-in-processing the data source manager before the application is run and creating a target connection pool in the cache, the problem of not being able to dynamically load data sources when configuring multiple data sources with a single type of application framework is solved, and dynamic loading and efficient resource utilization are achieved.

CN119576927APending Publication Date: 2025-03-07CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411599909.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

When configuring multiple data sources with a single type of application framework, you need to start the application after each configuration file changes, and the data source cannot be loaded dynamically, which increases server resource consumption.

Method used

By single-in-processing the data source manager before the application is run, the application supports the global uniqueness of the data source manager; create a target connection pool corresponding to the target data source in the cache of the target data source manager, and connect and access the target data source based on the target connection pool.

Benefits of technology

It realizes dynamic loading of data sources when the application is run, reduces server resource consumption and improves the reuse rate of database connections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119576927A_ABST
    Figure CN119576927A_ABST
Patent Text Reader

Abstract

The invention provides a data source access method and device, equipment, a storage medium and a program product, and can be applied to the technical field of computers. The method comprises the steps that before an application runs, single instantiation processing is carried out on a data source manager so as to support global uniqueness of the data source manager accessed by the application; determining a target data source manager and target data source information in response to a first access request of the target object for accessing the target data source based on the application; under the condition that multiple pieces of data source information of a buffer of the target data source manager do not include the target data source information, a target connection pool corresponding to the target data source is created in the buffer, and the buffer stores the multiple pieces of data source information with the established connection pool; and connecting the target data source based on the target connection pool, and performing an access operation on the target data source based on the first access request to obtain an access operation result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to a data source access method, device, equipment, storage medium, and program product. Background Art

[0002] In conventional development projects, the application platform usually connects to the database to perform operations such as adding, deleting, modifying, and querying. If it involves connecting to multiple databases, and the database types are inconsistent, it is necessary to connect multiple data sources. For example, in the same application, user A needs to connect to a relational database (mysql) to check the data in a certain table, and then connect to an object-relational database (oracle) to check the data in another table. User B needs to connect to a large-scale parallel analysis database to query some data, and user C also needs to connect to mysql to check some data. At this time, it is necessary to dynamically add some data source information during the application operation.

[0003] In the process of implementing the concept of the present disclosure, the inventors found that there are at least the following problems in the related technology: currently, when relying on a single type of application framework to configure multiple data sources, it is necessary to change the configuration file each time before starting the application, and the data source cannot be loaded dynamically, which increases server resource consumption. Summary of the invention

[0004] In view of this, the present disclosure provides a data source access method, apparatus, device, storage medium and program product.

[0005] One aspect of the present disclosure provides a data source access method, including: before an application runs, singletonizing a data source manager to support global uniqueness of the application accessing the data source manager; determining a target data source manager and target data source information in response to a first access request of a target object based on the application to access a target data source; when multiple data source information in a cache of the target data source manager does not include the target data source information, creating a target connection pool corresponding to the target data source in the cache, wherein the cache stores multiple data source information for which a connection pool has been established; connecting to the target data source based on the target connection pool, and performing an access operation on the target data source based on the first access request to obtain an access operation result.

[0006] According to an embodiment of the present disclosure, single-instance processing of a data source manager includes:

[0007] When the type of the application framework is the first application framework, the data source manager is singletonized based on the singleton function; when the type of the application framework is the second application framework, the data source manager is singletonized based on the object function managed by the inversion of control container.

[0008] According to an embodiment of the present disclosure, the data source access method further includes:

[0009] In response to a second access request of the target object based on an application to access a data source for which a connection pool has been established, a current timer moment of the connection pool corresponding to the data source is detected, wherein the current timer moment represents a remaining time that the current connection pool can connect to the data source; when the current timer moment is greater than a preset time threshold, the current timer moment of the connection pool is reset to an initial timer moment; and a connection is made to the data source based on the connection pool.

[0010] According to an embodiment of the present disclosure, the data source access method further includes:

[0011] When the current timer moment is equal to the preset time threshold, a connection pool corresponding to the data source is re-created in the cache, and an initial timer moment of the connection pool is configured.

[0012] According to an embodiment of the present disclosure, an access operation is performed on a target data source based on a first access request, and the access operation result obtained includes:

[0013] In the case where the first access request is a read or write operation request for table data, the callback function is called to perform read or write operations on the target data source to obtain table data operation results; in the case where the first access request is a query operation request for table structure attribute data, a query operation is performed on the target data source to obtain table structure attribute data operation results.

[0014] According to an embodiment of the present disclosure, the data source access method further includes:

[0015] When the disconnected time of a data source in the data source manager is greater than a preset expired data source time threshold, the connection pool and data source information corresponding to the data source are cleaned up.

[0016] According to an embodiment of the present disclosure, when the multiple data source information of the cache of the target data source manager does not include the target data source information, creating a target connection pool corresponding to the target data source in the cache includes:

[0017] When the multiple data source information in the cache of the target data source manager does not include the target data source information, determine the current number of connection pools in the target data source manager; when the current number is less than a preset connection pool number threshold, create a target connection pool corresponding to the target data source in the cache.

[0018] Another aspect of the present disclosure provides a data source access device, comprising:

[0019] The singleton module is used to singletonize the data source manager before the application runs, so as to support the global uniqueness of the application accessing the data source manager;

[0020] A response module, configured to determine a target data source manager and target data source information in response to a first access request of a target object to access a target data source based on an application;

[0021] A creation module, used for creating a target connection pool corresponding to the target data source in the buffer when the multiple data source information in the buffer of the target data source manager does not include the target data source information, wherein the buffer stores the multiple data source information of the established connection pool;

[0022] The access module is used to connect to the target data source based on the target connection pool, and to perform an access operation on the target data source based on the first access request to obtain an access operation result.

[0023] Another aspect of the present disclosure provides an electronic device, comprising:

[0024] one or more processors;

[0025] a memory for storing one or more programs,

[0026] When one or more programs are executed by one or more processors, the one or more processors implement the above data source access method.

[0027] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above data source access method when executed.

[0028] Another aspect of the present disclosure provides a computer program product, which includes computer executable instructions, and the instructions are used to implement the above data source access method when executed.

[0029] According to the data source access method, device, equipment, storage medium and program product provided by the present disclosure, the data source manager is processed as a singleton before the application runs; when the multiple data source information in the cache of the target data source manager does not include the target data source information, a target connection pool corresponding to the target data source is created in the cache; the target data source is connected based on the target connection pool, and the target data source is accessed based on the first access request to obtain the access operation result. Since the data source manager is processed as a singleton before the application runs, the global uniqueness of the application accessing the data source manager is guaranteed; the cache is used in the data source manager to support dynamic loading of the data source when the application runs, and a target connection pool corresponding to the target data source can be created in the cache without interrupting the application during the application running, and then the target data source is operated based on the target connection pool. When the data source connection is needed, the connection pool is directly obtained from the cache, and the connection pool is returned to the cache after the operation is completed, thereby improving the reuse rate of the database connection and reducing the consumption of server resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0031] Figure 1 The application scenario of the data source access method according to the embodiment of the present disclosure is schematically shown;

[0032] Figure 2 A flowchart of a data source access method according to an embodiment of the present disclosure is schematically shown;

[0033] Figure 3 An example schematic diagram of accessing multiple data sources according to an embodiment of the present disclosure is schematically shown;

[0034] Figure 4 A block diagram schematically shows a data source access device according to an embodiment of the present disclosure; and

[0035] Figure 5 A block diagram of an electronic device suitable for implementing a data source access method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0036] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0037] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0038] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0039] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0040] In the process of implementing the present disclosure, it was found that in conventional development projects, the application platform generally connects to the database to perform operations such as adding, deleting, modifying, and checking. If it involves connecting to multiple databases, and the database types are inconsistent, it is necessary to connect multiple data sources. For example, in the same application, user A needs to connect to the MySQL database to check the data of a certain table, and then connect to the Oracle database to check the data of another table. User B needs to connect to the large-scale parallel analysis database to query some data, and user C also needs to connect to MySQL to check some data. At this time, it is necessary to support dynamic addition of data sources during the application operation. However, when currently relying on a single type of application framework to configure multiple data sources, it is necessary to start the application each time after changing the configuration file, and the data source cannot be loaded dynamically, which increases server resource consumption.

[0041] In view of this, the embodiments of the present disclosure provide a data source access method, apparatus, device, storage medium and program product. The method includes: before the application runs, the data source manager is singletonized to support the global uniqueness of the application accessing the data source manager; in response to the first access request of the target object to access the target data source based on the application, the target data source manager and the target data source information are determined; when the multiple data source information in the cache of the target data source manager does not include the target data source information, a target connection pool corresponding to the target data source is created in the cache, wherein the cache stores multiple data source information of the established connection pool; the target data source is connected based on the target connection pool, and the target data source is accessed based on the first access request to obtain the access operation result.

[0042] It should be noted that the data source access method and data source access device determined in the present disclosure can be used in the financial field, and can also be used in any field other than the financial field. The application field of the data source access method and device determined in the present disclosure is not limited.

[0043] In the technical solution of the present disclosure, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0044] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0045] Figure 1 The application scenario of the data source access method according to the embodiment of the present disclosure is schematically illustrated.

[0046] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104 and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0047] The user may use at least one of the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0048] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0049] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0050] It should be noted that the data source access method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the data source access device provided in the embodiment of the present disclosure can generally be set in the server 105. The data source access method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the data source access device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0051] Alternatively, the data source access method provided in the embodiment of the present disclosure may also be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103, or may also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103. Accordingly, the data source access device provided in the embodiment of the present disclosure may also be provided in the first terminal device 101, the second terminal device 102, or the third terminal device 103, or may be provided in other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103.

[0052] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0053] Figure 2 The flowchart of the data source access method according to the embodiment of the present disclosure is schematically shown.

[0054] like Figure 2 As shown, the method 200 includes operations S210 to S240.

[0055] In operation S210, before the application is run, the data source manager is singletonized to support the global uniqueness of the application accessing the data source manager.

[0056] According to an embodiment of the present disclosure, the application may be a business transaction platform, and multiple user objects may connect to different data sources based on the application, and then perform operations such as reading and writing on the data sources. For example, the data source may be an Oracle database, a MySQL database (structured query language), and the like.

[0057] According to an embodiment of the present disclosure, the data source manager is used to manage multiple data sources, and parameter information of the data sources is recorded in the data source manager.

[0058] According to the embodiment of the present disclosure, before the application is run, a corresponding singleton function can be selected according to the application framework in the system, and then the data source manager is singletonized based on the singleton function. When the application is running, the global uniqueness of the application accessing the data source manager is guaranteed.

[0059] In operation S220 , in response to a first access request of a target object to access a target data source based on an application, a target data source manager and target data source information are determined.

[0060] According to an embodiment of the present disclosure, the target object represents a user who accesses an application, and the target data source represents a data source to be accessed by the target object based on the application.

[0061] According to an embodiment of the present disclosure, an application is started to run, and the server responds to receiving a first access request from a target object to access a target data source based on the application, and determines the target data source manager to be accessed by the application on the basis of singularizing the data source manager; and determines the target data source information according to the first access request.

[0062] According to an embodiment of the present disclosure, the first access request includes target data source information submitted by the target object in the application, such as a connection address, an account number, and a password.

[0063] In operation S230, when the plurality of data source information in the cache of the target data source manager does not include the target data source information, a target connection pool corresponding to the target data source is created in the cache.

[0064] According to an embodiment of the present disclosure, a target data source manager has a cache inside, which can be a cache. The cache is used to manage multiple data sources, and the cache stores connection pools that have been established corresponding to the multiple data sources. Multiple data source information and connection pool information are recorded in the cache, such as data source connection address, password, maximum number of connection pools, and other information.

[0065] According to an embodiment of the present disclosure, when multiple data source information in a cache does not include target data source information, it indicates that the target data source information is not stored in the cache and a target connection pool corresponding to the target data source is not established. Therefore, it is necessary to pass the target data source information into a globally unique data source manager and create a target connection pool corresponding to the target data source in the cache in the data source manager.

[0066] In operation S240, a connection is made to a target data source based on the target connection pool, and an access operation is performed on the target data source based on the first access request to obtain an access operation result.

[0067] According to an embodiment of the present disclosure, the first access request also includes a structured query language. The application obtains a target connection pool from a cache and then connects to a target data source. The structured query language is executed on the target data source to perform an access operation and obtain an access operation result.

[0068] For example, the access operation result may be a data query result of a field in the target data source.

[0069] According to the embodiments of the present disclosure, the data source manager is singletonized before the application is run, thereby ensuring the global uniqueness of the application accessing the data source manager; a cache is used in the data source manager to support dynamic loading of the data source when the application is running, and during the application operation, a target connection pool corresponding to the target data source can be created in the cache without interrupting the application, and then operations are performed on the target data source based on the target connection pool. When a data source connection is needed, the connection pool is directly obtained from the cache, and the connection pool is returned to the cache after the operation is completed, thereby improving the reuse rate of database connections and reducing server resource consumption.

[0070] According to an embodiment of the present disclosure, single-instance processing of a data source manager includes:

[0071] When the type of the application framework is the first application framework, the data source manager is singletonized based on the singleton function; when the type of the application framework is the second application framework, the data source manager is singletonized based on the object function managed by the inversion of control container.

[0072] According to an embodiment of the present disclosure, the first application framework can be a non-modular framework, and the modular framework is Spring. When the type of the application framework is a non-Spring framework, the data source manager can be singularized by using a singleton function to support the global uniqueness of the application accessing the data source manager.

[0073] According to an embodiment of the present disclosure, the second application framework may be a modular framework (spring). When the type of the application framework is a spring framework, the data source manager may be singletonized by utilizing an object function (Bean) managed by an inversion of control container to support global uniqueness of application access to the data source manager.

[0074] According to the embodiment of the present disclosure, the data source manager is handed over to the application framework for management. In this process, there is no need to rely on the spring framework. The singleton of the data source manager can be ensured in both the spring framework and the non-spring framework, thereby supporting the application to uniquely access the data source manager, obtain the target connection pool from the storage in the data source manager, and quickly and directly connect to the target data source without interrupting the application operation.

[0075] According to an embodiment of the present disclosure, the data source access method further includes:

[0076] In response to a second access request of the target object based on an application to access a data source for which a connection pool has been established, a current timer moment of the connection pool corresponding to the data source is detected, wherein the current timer moment represents a remaining time that the current connection pool can connect to the data source; when the current timer moment is greater than a preset time threshold, the current timer moment of the connection pool is reset to an initial timer moment; and a connection is made to the data source based on the connection pool.

[0077] According to an embodiment of the present disclosure, a buffer stores connection pools corresponding to multiple data sources, each of which has an initial timer moment for initialization, followed by a countdown. The initial timer moment represents the total time that the connection pool can connect to the data source.

[0078] According to an embodiment of the present disclosure, the server detects the current timer moment of the connection pool corresponding to the data source in response to a second access request of the target object based on an application to access a data source for which a connection pool has been established. The second access request includes a structured query statement.

[0079] According to an embodiment of the present disclosure, the current timer moment being greater than the preset time threshold indicates that the connection pool can still be used to connect to the data source, but there may be insufficient time to establish a connection. Therefore, the current timer moment of the connection pool needs to be reset to the initial timer moment.

[0080] For example, the preset time threshold is 0:0:0, the current timer time of the connection pool is 0:0:1, and the current timer time is greater than the preset time threshold. Therefore, the current timer time of the connection pool is reset to the initial timer time 1:1:1, and then the connection pool connection data source is obtained from the cache and the structured query statement is executed.

[0081] According to an embodiment of the present disclosure, the data source access method further includes:

[0082] When the current timer moment is equal to the preset time threshold, a connection pool corresponding to the data source is re-created in the cache, and an initial timer moment of the connection pool is configured.

[0083] According to an embodiment of the present disclosure, the current timer moment being equal to the preset time threshold indicates that the connection pool cannot connect to the data source and is in an invalid state. Therefore, a connection pool corresponding to the data source is recreated in the cache and the initial timer moment of the connection pool is initialized.

[0084] According to an embodiment of the present disclosure, a connection pool corresponding to a data source is recreated in a cache and an initial timer moment of the connection pool is configured, the connection pool connection data source is directly obtained from the cache and a structured query statement is executed.

[0085] According to an embodiment of the present disclosure, an access operation is performed on a target data source based on a first access request, and the access operation result obtained includes:

[0086] In the case where the first access request is a read or write operation request for table data, the callback function is called to perform read or write operations on the target data source to obtain table data operation results; in the case where the first access request is a query operation request for table structure attribute data, a query operation is performed on the target data source to obtain table structure attribute data operation results.

[0087] According to an embodiment of the present disclosure, table data is data stored on a target data source, and read and write operation requests for table data include requests for querying, deleting, and modifying the table data.

[0088] For example, the callback function may be a wrapper function (jdbctemplate). When the first access request is a delete operation request for the "city" field, the callback function is called to perform a delete operation on the target data source, and the table data operation result is table data that does not contain the "city" field.

[0089] According to an embodiment of the present disclosure, the table structure attribute data may be metadata such as table structure, field attributes, etc. When the first access request is a query operation request for table structure attribute data, a query operation is performed on the target data source, and a table structure attribute data operation result is returned.

[0090] According to an embodiment of the present disclosure, the data source access method further includes:

[0091] When the disconnected time of a data source in the data source manager is greater than a preset expired data source time threshold, the connection pool and data source information corresponding to the data source are cleaned up.

[0092] According to an embodiment of the present disclosure, before starting an application, the data source manager is initialized, such as configuring a preset expired data source time threshold. The preset expired data source time threshold represents the longest idle time of a data source in the data source manager.

[0093] According to an embodiment of the present disclosure, multiple data sources are stored in the data source manager. If the disconnection time of a data source is greater than a preset expiration data source time threshold, it indicates that the target object on the application has not requested access to the data source for a long time. Therefore, it is necessary to clean up the connection pool and data source information corresponding to the data source to release the memory of the data source manager.

[0094] According to an embodiment of the present disclosure, when the multiple data source information of the cache of the target data source manager does not include the target data source information, creating a target connection pool corresponding to the target data source in the cache includes:

[0095] When the multiple data source information in the cache of the target data source manager does not include the target data source information, determine the current number of connection pools in the target data source manager; when the current number is less than a preset connection pool number threshold, create a target connection pool corresponding to the target data source in the cache.

[0096] According to an embodiment of the present disclosure, initializing the data source manager may further include configuring a preset connection pool quantity threshold. The preset connection pool quantity threshold represents the maximum quantity of connection pools that can be stored in the memory.

[0097] According to an embodiment of the present disclosure, when multiple data source information in the cache of the target data source manager does not include the target data source information, it is necessary to first determine the current number of connection pools in the target data source manager. The current number is less than a preset connection pool number threshold, indicating that new connection pools can be created in the memory. Therefore, a target connection pool corresponding to the target data source is created in the cache.

[0098] According to an embodiment of the present disclosure, the current number is greater than a preset connection pool number threshold, indicating that no new connection pool can be created in the memory, and an access failure result is returned.

[0099] Figure 3 An example schematic diagram of multiple data source access according to an embodiment of the present disclosure is schematically shown.

[0100] like Figure 3 As shown, in the case of non-spring framework 301, the data source manager 303 is single-instanced based on the singleton function; in the case of spring framework 302, the data source manager 303 is single-instanced based on the object function managed by the inversion of control container; the data source manager 303 is initialized based on parameters such as the preset connection pool quantity threshold, the preset expired data source time threshold, etc.; the cache in the data source manager 303 includes the established connection pools corresponding to each of the multiple data sources and the newly created target connection pool corresponding to the target data source 304, and the established data sources include the first data source 305, the second data source 306, and the third data source 307, such as the first data source is the relational database mysqlsource, the second data source is the object-relational database oraclesource, and the third data source is the structural database postgresqlsource; in the case where the first access request is a read and write operation request for table data, the callback function 308 is called to perform the read and write operation 309; in the case where the first access request is a query operation request for table structure attribute data, the metadata query operation 310 is performed.

[0101] Based on the above data source access method, the present disclosure also provides a data source access device. Figure 4 The device is described in detail.

[0102] Figure 4 A structural block diagram of a data source access device according to an embodiment of the present disclosure is shown.

[0103] like Figure 4 As shown, the data source access device 400 of this embodiment includes a single instance module 410 , a response module 420 , a creation module 430 and an access module 440 .

[0104] The single instance module 410 is used to perform single instance processing on the data source manager before the application is run to support the global uniqueness of the application accessing the data source manager. In one embodiment, the single instance module 410 can be used to perform the operation S210 described above, which will not be repeated here.

[0105] The response module 420 is used to determine the target data source manager and target data source information in response to the first access request of the target object to access the target data source based on the application. In one embodiment, the response module 420 can be used to perform the operation S220 described above, which will not be repeated here.

[0106] The creation module 430 is used to create a target connection pool corresponding to the target data source in the cache when the multiple data source information in the cache of the target data source manager does not include the target data source information, wherein the cache stores multiple data source information for which the connection pool has been established. In one embodiment, the creation module 430 can be used to perform the operation S230 described above, which will not be repeated here.

[0107] The access module 440 is used to connect to the target data source based on the target connection pool, and to access the target data source based on the first access request to obtain an access operation result. In one embodiment, the access module 440 can be used to perform the operation S240 described above, which will not be described in detail here.

[0108] According to an embodiment of the present disclosure, the singleton module 410 includes a first singleton submodule and a second singleton submodule.

[0109] The first singletonization submodule is used to perform singletonization processing on the data source manager based on the singleton function when the type of the application framework is the first application framework.

[0110] The second singletonization submodule is used to perform singletonization processing on the data source manager based on the object function managed by the inversion of control container when the type of the application framework is the second application framework.

[0111] According to an embodiment of the present disclosure, the data source access device 400 further includes a detection module, a reset module and a connection module.

[0112] The detection module is used to detect the current timer moment of the connection pool corresponding to the data source in response to a second access request of the target object based on the application to access the data source for which the connection pool has been established, wherein the current timer moment represents the remaining time that the current connection pool can connect to the data source.

[0113] The reset module is used to reset the current timer time of the connection pool to the initial timer time when the current timer time is greater than the preset time threshold.

[0114] The connection module is used to connect to the data source based on the connection pool.

[0115] According to an embodiment of the present disclosure, the data source access device 400 further includes a configuration module.

[0116] The configuration module is used to recreate the connection pool corresponding to the data source in the cache and configure the initial timer time of the connection pool when the current timer time is equal to the preset time threshold.

[0117] According to an embodiment of the present disclosure, the access module 440 includes a first access submodule and a second access submodule.

[0118] The first access submodule is used to call the callback function when the first access request is a read or write operation request for table data, perform read or write operations on the target data source, and obtain a table data operation result.

[0119] The second access submodule is used to perform a query operation on the target data source to obtain a table structure attribute data operation result when the first access request is a query operation request for table structure attribute data.

[0120] According to an embodiment of the present disclosure, the data source access device 400 further includes a cleaning module.

[0121] The cleaning module is used to clean up the connection pool and data source information corresponding to the data source when the disconnection time of the data source in the data source manager is greater than the preset expired data source time threshold.

[0122] According to an embodiment of the present disclosure, the creation module 430 includes a determination submodule and a creation submodule.

[0123] The determination submodule is used to determine the current number of connection pools in the target data source manager when the multiple data source information in the buffer of the target data source manager does not include the target data source information.

[0124] The creation submodule is used to create a target connection pool corresponding to the target data source in the cache when the current number is less than a preset connection pool number threshold.

[0125] According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits, or at least part of the functions of any one of them can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as hardware circuits, such as field programmable gate arrays (FPGAs), programmable logic arrays (PLAs), systems on chips, systems on substrates, systems on packages, application specific integrated circuits (ASICs), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging circuits, or can be implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules, submodules, units, and subunits can be at least partially implemented as computer program modules, and when the computer program modules are run, the corresponding functions can be performed.

[0126] For example, any multiple of the single instance module 410, the response module 420, the creation module 430, and the access module 440 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present disclosure, at least one of the single instance module 410, the response module 420, the creation module 430, and the access module 440 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in a suitable combination of any of them. Alternatively, at least one of the singleton module 410 , the response module 420 , the creation module 430 , and the access module 440 may be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function may be performed.

[0127] Figure 5 A block diagram of an electronic device suitable for implementing a data source access method according to an embodiment of the present invention is shown.

[0128] Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0129] like Figure 5 As shown, the computer electronic device 500 according to an embodiment of the present invention includes a processor 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an on-board memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0130] In RAM 503, various programs and data required for the operation of electronic device 500 are stored. Processor 501, ROM 502 and RAM 503 are connected to each other via bus 504. Processor 501 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 502 and / or RAM 503. It should be noted that the program can also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in one or more memories.

[0131] Optionally, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the input / output (I / O) interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage portion 508 as needed.

[0132] Optionally, the method flow according to the embodiment of the present invention can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above-mentioned functions defined in the system of the embodiment of the present invention are executed. Optionally, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0133] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the data source access method according to the embodiment of the present invention is implemented.

[0134] Optionally, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.

[0135] For example, optionally, the computer-readable storage medium may include the ROM 502 and / or the RAM 503 described above and / or one or more memories other than the ROM 502 and the RAM 503 .

[0136] An embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the data source access method provided by the embodiment of the present invention.

[0137] When the computer program is executed by the processor 501, the above functions defined in the system / device of the embodiment of the present invention are performed. Optionally, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0138] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 509, and / or installed from the removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0139] Optionally, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages, specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, such as Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0140] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0141] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A data source access method, characterized in that: The method comprises: Before the application is run, the data source manager is singletonized to support the global uniqueness of the application accessing the data source manager; In response to a first access request of the target object to access the target data source based on the application, determining a target data source manager and target data source information; In a case where the multiple data source information in the cache of the target data source manager does not include the target data source information, creating a target connection pool corresponding to the target data source in the cache, wherein the cache stores the multiple data source information for which the connection pool has been established; The target data source is connected based on the target connection pool, and an access operation is performed on the target data source based on the first access request to obtain an access operation result.

2. The method according to claim 1, characterized in that Singleton processing of the data source manager includes: When the type of the application framework is the first application framework, performing singleton processing on the data source manager based on the singleton function; When the type of the application framework is the second application framework, the data source manager is singletonized based on the object function managed by the inversion of control container.

3. The method according to claim 1, characterized in that The method further comprises: In response to a second access request of the target object based on the application to access a data source for which a connection pool has been established, detecting a current timer moment of the connection pool corresponding to the data source, wherein the current timer moment represents a remaining time that the connection pool can currently connect to the data source; When the current timer time is greater than a preset time threshold, resetting the current timer time of the connection pool to an initial timer time; and The data source is connected based on the connection pool.

4. The method according to claim 3, characterized in that The method further comprises: When the current timer moment is equal to the preset time threshold, a connection pool corresponding to the data source is recreated in the cache, and the initial timer moment of the connection pool is configured.

5. The method according to claim 1, characterized in that An access operation is performed on the target data source based on the access request, and the access operation result obtained includes: In the case where the access request is a request for a read or write operation of table data, calling a callback function, performing a read or write operation on the target data source, and obtaining a table data operation result; In the case where the access request is a query operation request for table structure attribute data, a query operation is performed on the target data source to obtain a table structure attribute data operation result.

6. The method according to claim 1, characterized in that The method further comprises: When the disconnected time of a data source in the data source manager is greater than a preset expired data source time threshold, the connection pool corresponding to the data source and the data source information are cleared.

7. The method according to claim 1, characterized in that In a case where the plurality of data source information in the cache of the target data source manager does not include the target data source information, creating a target connection pool corresponding to the target data source in the cache includes: In a case where the plurality of data source information in the cache of the target data source manager does not include the target data source information, determining the current number of connection pools in the target data source manager; When the current number is less than a preset connection pool number threshold, a target connection pool corresponding to the target data source is created in the cache.

8. A data source access device, characterized in that: The device includes: A singleton module, used to perform singleton processing on the data source manager before the application is run, so as to support the global uniqueness of the application accessing the data source manager; A response module, configured to determine a target data source manager and target data source information in response to a first access request of a target object to access a target data source based on the application; a creation module, configured to create a target connection pool corresponding to the target data source in the buffer when the multiple data source information in the buffer of the target data source manager does not include the target data source information, wherein the buffer stores the multiple data source information for which the connection pool has been established; The access module is used to connect to the target data source based on the target connection pool, and to perform an access operation on the target data source based on the first access request to obtain an access operation result.

9. An electronic device, comprising: one or more processors; a memory for storing one or more programs, When one or more programs are executed by one or more processors, the one or more processors implement the method of any one of claims 1 to 7.

10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to implement the method of any one of claims 1 to 7.

11. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 7.