Data access method, device, equipment and storage medium based on J2EE

By receiving data access requests in the J2EE framework, matching the target database, and generating data access classes, the problem of low data access efficiency in the existing technology is solved, unified access to different databases is realized, and the data access efficiency is improved.

CN113515564BActive Publication Date: 2024-09-13SAI ANDY TECHNOLOGY (HONG KONG) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110538037.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-18
Publication Date
2024-09-13
Estimated Expiration
2041-05-18

AI Technical Summary

Technical Problem

The existing J2EE data access framework has many layers and cannot access data in a unified and simple way, resulting in low data access efficiency.

Method used

Provide a data access method based on J2EE. By receiving the data access request from the terminal, determine the target data access interface, match the target database, create metadata information, call the code generator to generate the data access class, convert it into a data query statement, obtain and Transfer data.

Benefits of technology

It improves the efficiency of data access, realizes unified access to different database types, and improves the efficiency of data access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113515564B
    Figure CN113515564B
Patent Text Reader

Abstract

The present invention relates to the field of big data, and discloses a J2EE-based data access method, device, equipment and storage medium for improving the efficiency of data access. The J2EE-based data access method comprises: receiving a data access request sent by a terminal, and determining a target data access interface according to the data access request; matching the data source of the target data access interface to obtain a target database corresponding to the target data access interface; creating target metadata information corresponding to the target database according to the target database; calling a preset code generator, and generating a target data access class corresponding to the target metadata information according to the target metadata information and the target database; converting the target data access class into a data query statement, and obtaining target data according to the data query statement, and transmitting the target data to the terminal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of big data, and in particular to a J2EE-based data access method, device, equipment and storage medium. Background Art

[0002] Data storage is the core of various applications. J2EE architecture is the mainstream architecture for data storage. J2EE provides a series of methods to save and extract data. Of course, data access is also essential. Due to the diversity of data sources, it is imperative to adopt a unified data access framework. J2EE provides a set of concise and efficient APIs for data "consumers" to access, modify and delete data. It can access various heterogeneous data sources in a unified way and provide a unified interface for application data access.

[0003] However, in the prior art, the data access framework has many levels, and it is impossible to access data in a unified and simple way, which reduces the efficiency of data access. Summary of the invention

[0004] The main purpose of the present invention is to solve the current technical problem of low data access efficiency.

[0005] A first aspect of the present invention provides a J2EE-based data access method, which includes: receiving a data access request sent by a terminal, and determining a target data access interface according to the data access request; performing data source matching on the target data access interface to obtain a target database corresponding to the target data access interface; creating target metadata information corresponding to the target database according to the target database; calling a preset code generator, and generating a target data access class corresponding to the target metadata information according to the target metadata information and the target database; converting the target data access class into a data query statement, acquiring target data according to the data query statement, and transmitting the target data to the terminal.

[0006] Optionally, in a first implementation method of the first aspect of the present invention, the data access request sent by the receiving terminal and determining the target data access interface based on the data access request include: receiving the data access request sent by the terminal; parsing the data access request to obtain interface information corresponding to the data access request, the interface information including an interface type; and querying the target data access interface corresponding to the data access request based on the interface type.

[0007] Optionally, in a second implementation method of the first aspect of the present invention, the data source matching of the target data access interface to obtain the target database corresponding to the target data access interface includes: obtaining a mapping relationship between the target data access interface and a preset data source, the data source including a relational database, a Nosql database, and an ElasticSearch database; and matching the target database corresponding to the target data access interface according to the mapping relationship.

[0008] Optionally, in a third implementation method of the first aspect of the present invention, creating target metadata information corresponding to the target database according to the target database includes: when the target database is a relational database, creating a database table, the database table including a library name, a schema name, a table name, a table field name and table field attributes; when the target database is a Nosql database, creating a column table, the column table including a key-value key value, an expiration time, a document structure and a column table structure; when the target database is an ElasticSearch database, creating field information, the field information including an index name, an index mapping field structure relationship and a field type; and determining the database table, the column table and the field information as target metadata information.

[0009] Optionally, in a fourth implementation manner of the first aspect of the present invention, calling a preset code generator and generating a target data access class corresponding to the target metadata information based on the target metadata information and the target database includes: when the target database is the relational database, obtaining a configuration file through the preset code generator and mapping the target metadata information to a first entity class, and the target metadata information is the database table; when the target database is the Nosql database, mapping the target metadata information to a map class through the code generator, and the target metadata information is the column table; when the target database is the ElasticSearch database, mapping the target metadata information to a second entity class through the code generator, and the target metadata information is the field information; and determining the first entity class, the map class and the second entity class as target data access classes.

[0010] Optionally, in a fifth implementation method of the first aspect of the present invention, converting the target data access class into a data query statement, acquiring target data according to the data query statement, and transmitting the target data to the terminal includes: converting the target data access class into multiple SQL query statements, splicing the multiple SQL query statements to obtain a data query statement; performing a data query in a data source based on the data query statement to obtain target data; converting the target data into json format, and transmitting the converted target data in json format to the terminal.

[0011] Optionally, in the sixth implementation method of the first aspect of the present invention, after converting the target data access class into a data query statement, acquiring the target data according to the data query statement, and transmitting the target data to the terminal, it also includes: calling a preset visualization interface to display the target data, and performing version migration on the target data.

[0012] The second aspect of the present invention provides a J2EE-based data access device, which includes: a receiving module, which is used to receive a data access request sent by a terminal, and determine a target data access interface according to the data access request; a matching module, which is used to match the data source of the target data access interface to obtain a target database corresponding to the target data access interface; a creation module, which is used to create target metadata information corresponding to the target database according to the target database; a generation module, which is used to call a preset code generator, and generate a target data access class corresponding to the target metadata information according to the target metadata information and the target database; a data acquisition module, which is used to convert the target data access class into a data query statement, and obtain target data according to the data query statement, and transmit the target data to the terminal.

[0013] Optionally, in a first implementation method of the second aspect of the present invention, the receiving module is specifically used to: receive a data access request sent by a terminal; parse the data access request to obtain interface information corresponding to the data access request, the interface information including an interface type; and query the target data access interface corresponding to the data access request according to the interface type.

[0014] Optionally, in a second implementation method of the second aspect of the present invention, the matching module is specifically used to: obtain a mapping relationship between the target data access interface and a preset data source, the data source including a relational database, a Nosql database, and an ElasticSearch database; and match the target database corresponding to the target data access interface according to the mapping relationship.

[0015] Optionally, in a third implementation method of the second aspect of the present invention, the creation module is specifically used to: when the target database is a relational database, create a database table, the database table includes a library name, a schema name, a table name, a table field name and table field attributes; when the target database is a Nosql database, create a column table, the column table includes a key-value key value, an expiration time, a document structure and a column table structure; when the target database is an ElasticSearch database, create field information, the field information includes an index name, an index mapping field structure relationship and a field type; determine the database table, the column table and the field information as target metadata information.

[0016] Optionally, in a fourth implementation manner of the second aspect of the present invention, the generation module is specifically used to: when the target database is the relational database, obtain the configuration file through a preset code generator and map the target metadata information to a first entity class, and the target metadata information is the database table; when the target database is the Nosql database, map the target metadata information to a map class through the code generator, and the target metadata information is the column table; when the target database is the ElasticSearch database, map the target metadata information to a second entity class through the code generator, and the target metadata information is the field information; determine the first entity class, the map class and the second entity class as target data access classes.

[0017] Optionally, in a fifth implementation of the second aspect of the present invention, the data acquisition module is specifically used to: convert the target data access class into multiple SQL query statements, concatenate the multiple SQL query statements to obtain a data query statement; perform data query in the data source based on the data query statement to obtain target data; convert the target data into json format, and transmit the converted target data in json format to the terminal.

[0018] Optionally, in a sixth implementation of the second aspect of the present invention, the J2EE-based data access device further includes: a visualization module, configured to call a preset visualization interface to display the target data and perform version migration on the target data.

[0019] The third aspect of the present invention provides a J2EE-based data access device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the J2EE-based data access device executes the above-mentioned J2EE-based data access method.

[0020] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned J2EE-based data access method.

[0021] In the technical solution provided by the present invention, a data access request sent by a terminal is received, and a target data access interface is determined according to the data access request; a data source is matched on the target data access interface to obtain a target database corresponding to the target data access interface; target metadata information corresponding to the target database is created according to the target database; a preset code generator is called, and a target data access class corresponding to the target metadata information is generated according to the target metadata information and the target database; the target data access class is converted into a data query statement, and target data is obtained according to the data query statement, and the target data is transmitted to the terminal. The present invention improves the efficiency of data access. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A schematic diagram of an embodiment of a data access method based on J2EE in an embodiment of the present invention;

[0023] Figure 2 A schematic diagram of another embodiment of a J2EE-based data access method in an embodiment of the present invention;

[0024] Figure 3 A schematic diagram of an embodiment of a J2EE-based data access device in an embodiment of the present invention;

[0025] Figure 4 It is a schematic diagram of another embodiment of a J2EE-based data access device in an embodiment of the present invention;

[0026] Figure 5 The figure is a schematic diagram of an embodiment of a J2EE-based data access device in an embodiment of the present invention. DETAILED DESCRIPTION

[0027] Embodiments of the present invention provide a data access method, apparatus, device and storage medium based on J2EE. The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or precedence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described here can be implemented in an order other than that illustrated or described here. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the data access method based on J2EE in the embodiment of the present invention includes:

[0029] 101. Receive a data access request sent by a terminal, and determine a target data access interface according to the data access request;

[0030] It is understandable that the execution subject of the present invention may be a J2EE-based data access device, or a terminal or a server, which is not specifically limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.

[0031] The server receives a data access request sent by a terminal. For example, if the server receives a data access request sent by a terminal carrying the terminal type of the terminal, the server parses the data access request based on the terminal type and the data access request, and obtains interface information corresponding to the data access request. Finally, the server queries the preset data access interface according to the interface information to obtain the corresponding target data access interface. The target data access interface, for example: the target data access interface includes a public interface and a private interface, and both the public interface and the private interface are interfaces set according to a preset area. According to the interface information, the data access interface in the preset area is queried to obtain the target data access interface.

[0032] It should be noted that the terminal of this embodiment may include an iOS terminal of an Apple system and an Android terminal of an Android system, but is not limited thereto. The terminal and the server may be connected via various wireless communication methods, and the present invention does not limit this.

[0033] 102. Perform data source matching on the target data access interface to obtain a target database corresponding to the target data access interface;

[0034] The server matches the data source of the target data access interface to obtain the target database corresponding to the target data access interface. The data sources include: relational database, non-relational database (Not Only sql, Nosql) and distributed database (ElasticSearch, ES).

[0035] 103. Create target metadata information corresponding to the target database according to the target database;

[0036] The server obtains the database type of the target database, which is one of relational, Nosql, and ElasticSearch, and then creates the target metadata information of the corresponding target database according to the database type. The server defines the metadata of the target database according to the database type. For example, if the database type of the target database is a relational database, the table structure information is defined; if the database type of the target database is Nosql, the key name and key value data structure are defined; if the database type of the target database is an ElasticSearch database, the index field structure is defined.

[0037] 104. Calling a preset code generator, and generating a target data access class corresponding to the target metadata information according to the target metadata information and the target database;

[0038] The server completes the target metadata information, and then generates the corresponding target data access class based on the target metadata information. The target data access class generated for different database types is also different. For example, if the database type is relational, the database table (i.e., the target metadata information) is mapped to the entity class (i.e., the target data access class); if the database type is a Nosql database, the key name (i.e., the target metadata information) is defined as the map class (i.e., the target data access class); if the database type is an ElasticSearch database, the index field (i.e., the target metadata information) is mapped to the entity class (i.e., the target data access class).

[0039] 105. Convert the target data access class into a data query statement, obtain the target data according to the data query statement, and transmit the target data to the terminal.

[0040] The server converts the target data access class into a data query statement, queries the target database through the data query statement, obtains the target data, converts the target data into JSON format data, and transmits the JSON format data to the terminal.

[0041] In an embodiment of the present invention, a data access request sent by a terminal is received, and a target data access interface is determined according to the data access request; a data source is matched on the target data access interface to obtain a target database corresponding to the target data access interface; target metadata information corresponding to the target database is created according to the target database; a preset code generator is called, and a target data access class corresponding to the target metadata information is generated according to the target metadata information and the target database; the target data access class is converted into a data query statement, and target data is obtained according to the data query statement, and the target data is transmitted to the terminal. The present invention unifies the data access interface so that data of different database types and different data structures are integrated during data access, thereby improving the efficiency of data access.

[0042] See also Figure 2 Another embodiment of the J2EE-based data access method in the embodiment of the present invention includes:

[0043] 201. Receive a data access request sent by a terminal, and determine a target data access interface according to the data access request;

[0044] The server receives a data access request sent by a terminal. For example, if the server receives a data access request sent by a terminal carrying the terminal type of the terminal, the server parses the data access request based on the terminal type and the data access request to obtain the interface information corresponding to the data access request. Finally, the preset data access interface is queried according to the interface information to obtain the corresponding target data access interface. For example, the target data access interface includes a public interface and a private interface, and both the public interface and the private interface are interfaces set according to a preset area. According to the interface information, the data access interface in the preset area is queried to obtain the target data access interface.

[0045] It should be noted that the terminal of this embodiment may include an iOS terminal of an Apple system and an Android terminal of an Android system, but is not limited thereto. The terminal and the server may be connected via various wireless communication methods, and the present invention does not limit this.

[0046] Optionally, step 201 includes: receiving a data access request sent by a terminal; parsing the data access request to obtain interface information corresponding to the data access request, the interface information including an interface type; and querying a target data access interface corresponding to the data access request according to the interface type.

[0047] The server receives a data access request sent by the terminal, parses the interface information of the data access request, obtains the interface information, and queries the target data access interface corresponding to the data access request based on the interface information. The interface types include public interfaces and private interfaces. The public interface refers to an interface that can be shared by all terminals, and the private interface refers to an interface exclusive to a certain type of terminal. The public interface is set in a storage area, and the private interface of each type of client (i.e., terminal) is set in another storage area for querying the target data access interface corresponding to the data access request.

[0048] 202. Perform data source matching on the target data access interface to obtain a target database corresponding to the target data access interface;

[0049] The server matches the data source of the target data access interface to obtain the target database corresponding to the target data access interface. The data sources include: relational database, non-relational database (Not Only sql, Nosql) and distributed database (ElasticSearch, ES).

[0050] Optionally, step 202 includes: obtaining a mapping relationship between a target data access interface and a preset data source, the data source including a relational database, a Nosql database, and an ElasticSearch database; and matching a target database corresponding to the target data access interface according to the mapping relationship.

[0051] Specifically, the server pre-configures the correspondence between the data access interface and the data source, and stores the correspondence in a configuration file, wherein the data source includes a relational database, a Nosql database, and an ElasticSearch database. A relational database is a database that uses a relational model to organize data. A relational database stores data in the form of rows and columns. The rows and columns used to store data are called tables, and a group of tables constitute a database. Nosql databases are easy to expand, have large amounts of data, and have high performance. Nosql databases have very high read and write performance. ElasticSearch databases are distributed, highly scalable, and highly real-time search and data analysis engines that can search, analyze, and explore large amounts of data. The server matches the preset data source through the target data access interface and the correspondence to obtain the target database.

[0052] 203. Create target metadata information corresponding to the target database according to the target database;

[0053] The server obtains the database type of the target database, which is one of relational, Nosql, and ElasticSearch, and then creates the target metadata information of the corresponding target database according to the database type. The server defines metadata for the target database according to the database type. For example, if the database type of the target database is a relational database, the table structure information (i.e., metadata) of the target database is defined; if the database type of the target database is Nosql, the target database is defined based on the key name and key value data structure (i.e., metadata); if the database type of the target database is an ElasticSearch database, the index field structure (i.e., metadata) of the target database is defined.

[0054] Optionally, step 203 includes: when the target database is a relational database, creating a database table, the database table including a library name, a schema name, a table name, a table field name and table field attributes; when the target database is a Nosql database, creating a column table, the column table including a key-value key value, an expiration time, a document structure and a column table structure; when the target database is an ElasticSearch database, creating field information, the field information including an index name, an index mapping field structure relationship and a field type; and determining the database table, the column table and the field information as target metadata information.

[0055] When the data source is a relational database, the server creates a database table (i.e., target metadata information) including the library name, schema name, table name, table field name, and table field attributes. When the data source is a Nosql database, the created column table (i.e., target metadata information) includes: key-value key value and expiration time, document structure, and column table structure. When the data source is an ElasticSearch database, the created field information (i.e., target metadata information) includes: index name, index mapping field structure, and field type. In addition, the server also saves the target metadata information by establishing a metadata information library for the target metadata information.

[0056] 204. Calling a preset code generator, and generating a target data access class corresponding to the metadata information according to the target metadata information and the target database;

[0057] The server completes the target metadata information, and then generates the corresponding target data access class based on the target metadata information. The target data access class generated for different database types is also different. For example: if the database type is relational, the database table is mapped to the first entity class (i.e., the target data access class); if the database type is a Nosql database, a map class of the key name is defined (i.e., the target data access class); if the database type is an ElasticSearch database, the index field is mapped to the second entity class (i.e., the target data access class).

[0058] Optionally, step 204 includes: when the target database is the relational database, obtaining a configuration file through a preset code generator and mapping the target metadata information to a first entity class, and the target metadata information is the database table; when the target database is the Nosql database, mapping the target metadata information to a map class through the code generator, and the target metadata information is the column table; when the target database is the ElasticSearch database, mapping the target metadata information to a second entity class through the code generator, and the target metadata information is the field information; and determining the first entity class, the map class and the second entity class as target data access classes.

[0059] The server generates an entity java class (i.e., target metadata information) according to a preset code generator and a database table. The preset code generator may be the open source java framework mybatis, and the database table may be a relational database table. Furthermore, the server automatically creates a database table and can automatically generate an entity java class for table mapping and use a groovy script to create an sql file. The specific steps are as follows: perfect the metadata information and generate relevant entity classes according to the metadata information: if the target database is a relational database, map the database table to the first entity class; if the target database is a Nosql database, define the key name as a map class; if the target database is an ElasticSearch database, map the index name, index mapping field structure relationship, and field type to the second entity class.

[0060] 205. Convert the target data access class into multiple SQL query statements, and concatenate the multiple SQL query statements to obtain a data query statement;

[0061] The server converts the target data access class into a data query statement, converts the target data access class into multiple SQL query statements, and concatenates the multiple SQL query statements to obtain the data query statement.

[0062] 206. Perform data query in the data source based on the data query statement to obtain target data;

[0063] The server obtains the target data from the data source according to the data query statement. When the result of the data query is empty, it decides whether to execute the database query operation according to the preset query option configuration item, that is, obtains the cache configuration parameters. If the query option configuration item in the cache configuration parameters is to query the database when the query cache is not found, it is necessary to call the database cache strategy class to execute the database query operation, and finally use the result of executing the database query operation as the target data.

[0064] 207. Convert the target data into JSON format, and transmit the converted target data in JSON format to the terminal.

[0065] Specifically, the server converts the target data into JSON format. When converting the format, the object is enclosed in brackets. Each JSON value is represented by a key-value pair. The key and value are separated by a colon and the key must be a string type. The JSON values ​​are separated by commas. The array is enclosed in square brackets. The class instance is converted into a JSON object, and the JSON string is returned to obtain the target data after the format conversion. The target data after the format conversion is transmitted to the data access request terminal through a preset data channel.

[0066] Optionally, after step 207, the method further includes: calling a preset visualization interface to display the target data, and performing version migration on the target data.

[0067] The user can display the target data through the visualization interface, and the server sets parameters for the visualization interface to obtain a display interface, such as a web page theme style, a pie chart, and a line chart.

[0068] The server updates the target data and performs version change control management on the target data. Each time the target data version information changes, the server adds the metadata information of the new version while retaining the original target data version information. The version number is increased by 0.1, and the historical version of the target data information is viewed through a visual interface to achieve automatic data migration.

[0069] The server performs version migration on the target data. First, the system version table is used to record the version information when the metadata information is first created. The initial version number is v1.0, and the current system effective version number is v1.0. At the same time, a full set of SQL script files are provided, including data manipulation language (DML) and data definition language (DDL). Nosql databases and ElasticSearch databases provide a full set of json format files. The file names of SQL script files and json files are suffixed with version numbers for subsequent automatic upgrade operations. Relational databases trigger table structure change events by creating database trigger functions, and generate incremental DDL statement SQL script files based on table change events. The generated SQL script file name suffix is ​​the changed version number. Nosql databases and ElasticSearch databases are modified through the web interface to provide incremental json format files. In addition, the server will record the details of each change to the target data, the incremental script file of the change, and the current effective version number. When the system starts, it will trigger a change detection task to compare whether the current effective version number of the system version table is consistent with the provided incremental script file version number. If the current system effective version number is a historical version, then version migration will be triggered, and automatic version migration of the target data will be achieved by executing the incremental script.

[0070] The above describes the J2EE-based data access method in the embodiment of the present invention. The following describes the J2EE-based data access device in the embodiment of the present invention. Figure 3 In one embodiment of the present invention, a data access device based on J2EE includes:

[0071] The receiving module 301 is used to receive a data access request sent by a terminal and determine a target data access interface according to the data access request;

[0072] A matching module 302 is used to perform data source matching on the target data access interface to obtain a target database corresponding to the target data access interface;

[0073] A creation module 303 is used to create target metadata information corresponding to the target database according to the target database;

[0074] A generating module 304 is used to call a preset code generator and generate a target data access class corresponding to the target metadata information according to the target metadata information and the target database;

[0075] The data acquisition module 305 is used to convert the target data access class into a data query statement, acquire target data according to the data query statement, and transmit the target data to the terminal.

[0076] In an embodiment of the present invention, a data access request sent by a terminal is received, and a target data access interface is determined according to the data access request; a data source is matched on the target data access interface to obtain a target database corresponding to the target data access interface; target metadata information corresponding to the target database is created according to the target database; a preset code generator is called, and a target data access class corresponding to the target metadata information is generated according to the target metadata information and the target database; the target data access class is converted into a data query statement, and target data is obtained according to the data query statement, and the target data is transmitted to the terminal. The present invention improves the efficiency of data access.

[0077] See also Figure 4 Another embodiment of the J2EE-based data access device in the embodiment of the present invention includes:

[0078] The receiving module 301 is used to receive a data access request sent by a terminal and determine a target data access interface according to the data access request;

[0079] A matching module 302 is used to perform data source matching on the target data access interface to obtain a target database corresponding to the target data access interface;

[0080] A creation module 303 is used to create target metadata information corresponding to the target database according to the target database;

[0081] A generating module 304 is used to call a preset code generator and generate a target data access class corresponding to the target metadata information according to the target metadata information and the target database;

[0082] The data acquisition module 305 is used to convert the target data access class into a data query statement, acquire target data according to the data query statement, and transmit the target data to the terminal.

[0083] The visualization module 306 is used to call a preset visualization interface to display the target data and perform version migration on the target data.

[0084] Optionally, the receiving module 301 is specifically used to: receive a data access request sent by a terminal; parse the data access request to obtain interface information corresponding to the data access request, the interface information including an interface type; and query a target data access interface corresponding to the data access request according to the interface type.

[0085] Optionally, the matching module 302 is specifically used to: obtain a mapping relationship between the target data access interface and a preset data source, the data source including a relational database, a Nosql database and an ElasticSearch database; and match a target database corresponding to the target data access interface according to the mapping relationship.

[0086] Optionally, the creation module 303 is specifically used to: when the target database is a relational database, create a database table, the database table includes a library name, a schema name, a table name, a table field name and table field attributes; when the target database is a Nosql database, create a column table, the column table includes key-value key value, expiration time, document structure and column table structure; when the target database is an ElasticSearch database, create field information, the field information includes an index name, an index mapping field structure relationship and a field type; determine the database table, the column table and the field information as target metadata information.

[0087] Optionally, the generation module 304 is specifically used for: when the target database is the relational database, obtaining the configuration file through a preset code generator and mapping the target metadata information to a first entity class, and the target metadata information is the database table; when the target database is the Nosql database, mapping the target metadata information to a map class through the code generator, and the target metadata information is the column table; when the target database is the ElasticSearch database, mapping the target metadata information to a second entity class through the code generator, and the target metadata information is the field information; determining the first entity class, the map class and the second entity class as target data access classes.

[0088] Optionally, the data acquisition 305 module is specifically used to: convert the target data access class into multiple SQL query statements, concatenate the multiple SQL query statements to obtain a data query statement; perform data query in the data source based on the data query statement to obtain target data; convert the target data into json format, and transmit the converted target data in json format to the terminal.

[0089] above Figure 3and Figure 4 The J2EE-based data access device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The J2EE-based data access device in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0090] Figure 5 1 is a schematic diagram of the structure of a J2EE-based data access device provided by an embodiment of the present invention. The J2EE-based data access device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (for example, one or more processors) and a memory 520, and one or more storage media 530 (for example, one or more mass storage devices) storing application programs 533 or data 532. Among them, the memory 520 and the storage medium 530 may be temporary storage or permanent storage. The program stored in the storage medium 530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the J2EE-based data access device 500. Furthermore, the processor 510 may be configured to communicate with the storage medium 530 to execute a series of instruction operations in the storage medium 530 on the J2EE-based data access device 500.

[0091] The J2EE-based data access device 500 may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and / or one or more operating systems 531, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that Figure 5 The illustrated J2EE-based data access device structure does not constitute a limitation on the J2EE-based data access device, and may include more or less components than those illustrated, or may combine certain components, or may have different component arrangements.

[0092] The present invention also provides a J2EE-based data access device, which includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor executes the steps of the J2EE-based data access method in the above-mentioned embodiments.

[0093] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the J2EE-based data access method.

[0094] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0095] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0096] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data access method based on J2EE, characterized in that: The J2EE-based data access method includes: Receiving a data access request sent by a terminal, and determining a target data access interface according to the data access request; Obtaining a mapping relationship between the target data access interface and a preset data source, wherein the data source includes a relational database, a Nosql database, and an ElasticSearch database; According to the mapping relationship, matching the target database corresponding to the target data access interface; When the target database is a relational database, a database table is created, wherein the database table includes a database name, a schema name, a table name, a table field name, and table field attributes; When the target database is a Nosql database, a column table is created, wherein the column table includes a key-value, an expiration time, a document structure, and a column table structure; When the target database is an ElasticSearch database, create field information, the field information including index name, index mapping field structure relationship and field type; Determine the database table, the column table and the field information as target metadata information; Calling a preset code generator, and generating a target data access class corresponding to the target metadata information according to the target metadata information and the target database; The target data access class is converted into a data query statement, and target data is acquired according to the data query statement, and the target data is transmitted to the terminal.

2. The J2EE-based data access method according to claim 1, characterized in that: The receiving a data access request sent by a terminal and determining a target data access interface according to the data access request comprises: receiving a data access request sent by a terminal; Parsing the data access request to obtain interface information corresponding to the data access request, wherein the interface information includes an interface type; The target data access interface corresponding to the data access request is queried according to the interface type.

3. The J2EE-based data access method according to claim 1, characterized in that: The calling of the preset code generator and generating the target data access class corresponding to the target metadata information according to the target metadata information and the target database includes: When the target database is the relational database, a configuration file is obtained through a preset code generator and the target metadata information is mapped to a first entity class, and the target metadata information is the database table; When the target database is the Nosql database, the target metadata information is mapped to a map class by the code generator, and the target metadata information is the column table; When the target database is the ElasticSearch database, mapping the target metadata information to a second entity class through the code generator, the target metadata information being the field information; The first entity class, the map class and the second entity class are determined as target data access classes.

4. The J2EE-based data access method according to claim 1, characterized in that: The converting the target data access class into a data query statement, acquiring target data according to the data query statement, and transmitting the target data to the terminal includes: Convert the target data access class into multiple SQL query statements, and concatenate the multiple SQL query statements to obtain a data query statement; Performing data query in the data source based on the data query statement to obtain target data; The target data is converted into JSON format, and the converted target data in JSON format is transmitted to the terminal.

5. The J2EE-based data access method according to any one of claims 1 to 4, characterized in that: After converting the target data access class into a data query statement, acquiring target data according to the data query statement, and transmitting the target data to the terminal, the method further includes: A preset visualization interface is called to display the target data and to perform version migration on the target data.

6. A data access device based on J2EE, characterized in that: The J2EE-based data access device comprises: A receiving module, used for receiving a data access request sent by a terminal, and determining a target data access interface according to the data access request; A matching module is used to obtain a mapping relationship between the target data access interface and a preset data source, wherein the data source includes a relational database, a Nosql database, and an ElasticSearch database; and match a target database corresponding to the target data access interface according to the mapping relationship; A creation module is used to create a database table when the target database is a relational database, the database table includes a library name, a schema name, a table name, a table field name and table field attributes; when the target database is a Nosql database, create a column table, the column table includes a key-value key value, an expiration time, a document structure and a column table structure; when the target database is an ElasticSearch database, create field information, the field information includes an index name, an index mapping field structure relationship and a field type; determine the database table, the column table and the field information as target metadata information; A generation module, used to call a preset code generator and generate a target data access class corresponding to the target metadata information according to the target metadata information and the target database; The data acquisition module is used to convert the target data access class into a data query statement, acquire target data according to the data query statement, and transmit the target data to the terminal.

7. A data access device based on J2EE, characterized in that: The J2EE-based data access device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instruction in the memory so that the J2EE-based data access device executes the J2EE-based data access method according to any one of claims 1-5.

8. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by the processor, the J2EE-based data access method according to any one of claims 1 to 5 is implemented.