Data processing method and device in block chain, electronic equipment and storage medium

Through the Java virtual machine parsing and sending SQL operation requests to the SQL contract execution engine, the problem of cumbersome data operation in traditional blockchain is solved, and the convenience and efficiency of cross-contract data operation is achieved.

CN120216562APending Publication Date: 2025-06-27HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510221925.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

In traditional alliance blockchain systems, the data operation of smart contracts depends on EVM or JVM, resulting in cumbersome data operation and does not support SQL queries, reducing compatibility and ease of use with traditional databases.

Method used

The SQL operation request is parsed through the Java virtual machine, packaged into a cross-contract request object, and then verified and sent to the SQL contract execution engine to realize SQL operations on blockchain ledger data.

Benefits of technology

It realizes cross-contract data operation between the Java virtual machine and the SQL contract execution engine, allowing developers to use SQL statements in Java contracts to operate blockchain data easily and quickly, improving the efficiency and ease of use of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216562A_ABST
    Figure CN120216562A_ABST
Patent Text Reader

Abstract

The invention relates to a data processing method and device in a block chain, electronic equipment and a storage medium, and the method comprises the steps: analyzing an SQL operation request through a Java virtual machine under the condition that the SQL operation request is received, and packaging an analysis result into a cross-contract request object; verifying the Java virtual machine, and sending the cross-contract request object to an SQL contract execution engine through the Java virtual machine under the condition that the verification is passed; and after the SQL contract execution engine receives the cross-contract request, operating account book data on the block chain based on the cross-contract request, returning an operation result to the Java virtual machine, and converting the operation result into an operable result set in the Java virtual machine based on the Java virtual machine. Through application of the method and the device, the problem that data operation in a block chain is relatively tedious due to the fact that data of a block chain account book is read and written in in a key-value pair form through an intelligent contract code is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technologies, and in particular, to a data processing method and apparatus, an electronic device, and a storage medium in a blockchain. Background Art

[0002] In a traditional consortium blockchain system, the execution of smart contracts usually depends on engines such as the Ethereum Virtual Machine (EVM) or the Java Virtual Machine (JVM). These virtual machines provide an execution environment for smart contracts, but their operation modes are significantly different from those of traditional databases. In particular, with the development of blockchain technology, execution engines that support the execution of Structured Query Language (SQL) contracts have gradually emerged, enabling developers to directly operate on-chain ledger data through SQL statements. However, when processing stored data, the EVM and JVM do not directly support the SQL query method. They usually require developers to read and write data in the blockchain ledger in the form of key-value pairs through smart contract code. Although the existing method adapts to the decentralized and immutable characteristics of the blockchain, it makes data operations more cumbersome and inefficient. When writing smart contracts, developers must handle more underlying data access logic, reducing the compatibility and usability with traditional relational databases.

[0003] In view of the above problems in the related art, there is currently no effective solution. Summary of the Invention

[0004] This application provides a data processing method and apparatus, an electronic device, and a storage medium in a blockchain to solve the problem in the related art that data operations in the blockchain are relatively cumbersome by reading and writing data in the blockchain ledger in the form of key-value pairs through smart contract code.

[0005] In a first aspect, this application provides a data processing method in a blockchain, including: when receiving an SQL operation request, parsing the SQL operation request through a Java virtual machine and packaging the parsing result into a cross-contract request object; where the Java virtual machine provides an execution environment for Java contracts; verifying the Java virtual machine, and when the verification passes, sending the cross-contract request object to an SQL contract execution engine through the Java virtual machine; after the SQL contract execution engine receives the cross-contract request, operating on the ledger data on the blockchain based on the cross-contract request, returning the operation result to the Java virtual machine, and converting the operation result into a result set that can be operated on in the Java virtual machine based on the Java virtual machine.

[0006] Optionally, upon receiving an SQL operation request, the SQL operation request is parsed by a Java virtual machine, and the parsing result is packaged into a cross-contract request object, including: identifying the content in the SQL statement of the SQL operation request through an SQL parser; extracting the content and binding the content to the parameters in the Java contract; packaging the bound parameters and content into the cross-contract request object, where the cross-contract request object includes the complete information of the SQL operation.

[0007] Optionally, the Java virtual machine is verified, including: verifying the permission of the Java virtual machine to access the SQL contract, and verifying the data consistency of the Java virtual machine through a distributed transaction protocol.

[0008] Optionally, the ledger data on the blockchain is operated based on the cross-contract request, including: performing at least one of the following operations on the ledger data on the blockchain based on the SQL statement in the cross-contract request: querying, inserting, updating, deleting; verifying the legality of the operation based on the SQL contract execution engine; and obtaining the result of the operation execution when the verification passes.

[0009] Optionally, the operation result is converted into a result set operable in the Java virtual machine based on the Java virtual machine, including: when the operation result is a query result, converting the query result into a ResultSet object, or returning a status indicating success or failure according to the operation type; when the operation result is the result of an update operation, an insert operation, or a delete operation, converting the operation result into the number of affected rows in the contract or a status code indicating whether the operation is successful.

[0010] Optionally, the method further includes: when the execution of the SQL statement by the Java virtual machine fails, handling the failed operation through an exception capture mechanism and performing a transaction rollback to revoke the failed operation, or using a distributed transaction protocol for global rollback to ensure the consistency of all participating contract data.

[0011] In a second aspect, the present application provides a data processing device in a blockchain, including: a first processing module, configured to, when receiving an SQL operation request, parse the SQL operation request through a Java virtual machine and package the parsing result into a cross-contract request object; wherein, the Java virtual machine provides an execution environment for Java contracts; a second processing module, configured to verify the Java virtual machine, and when the verification is passed, send the cross-contract request object to an SQL contract execution engine through the Java virtual machine; a third processing module, configured to, after the SQL contract execution engine receives the cross-contract request, operate on ledger data on the blockchain based on the cross-contract request, return the operation result to the Java virtual machine, and convert the operation result into a result set operable in the Java virtual machine based on the Java virtual machine.

[0012] Optionally, the first processing module includes: an identification unit, configured to identify the content in the SQL statement in the SQL operation request through an SQL parser; a first processing unit, configured to extract the content and bind the content to parameters in the Java contract; a second processing unit, configured to package the bound parameters and content into the cross-contract request object, wherein the cross-contract request object includes complete information of the SQL operation.

[0013] In a third aspect, the present application provides an electronic device, including: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; at least one memory connected to the at least one bus, wherein the processor is configured to execute the data processing method in the blockchain described in the first aspect of the present application above.

[0014] In a fourth aspect, the present application further provides a computer storage medium storing computer-executable instructions, and the computer-executable instructions are used to execute the data processing method in the blockchain described in the first aspect of the present application above.

[0015] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: For the method provided by the embodiments of the present application, when receiving an SQL operation request, the SQL operation request is parsed by the Java virtual machine, and the parsing result is packaged into a cross-contract request object; then, the Java virtual machine is verified, and when the verification passes, the cross-contract request object is sent to the SQL contract execution engine through the Java virtual machine. After the SQL contract execution engine receives the cross-contract request, it operates on the ledger data on the blockchain based on the cross-contract request, and returns the operation result to the Java virtual machine, and converts the operation result into a result set that can be operated on in the Java virtual machine based on the Java virtual machine, thereby realizing cross-contract data operations between the Java virtual machine and the SQL contract execution engine. That is, through the embodiments of the present application, developers can operate on the ledger data in the form of SQL statements across SQL contracts in Java contracts, and utilize the flexibility of Java as a high-level language, so that complex contract logics can be easily written, making data processing operations in the blockchain more convenient and fast. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0018] One or more embodiments are exemplarily illustrated by the pictures in the corresponding accompanying drawings. These exemplary illustrations do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings are represented as similar elements, unless otherwise stated, and the drawings in the drawings do not constitute a proportional limitation.

[0019] Figure 1 It is a flowchart of a method for data processing in a blockchain provided by an embodiment of the present application;

[0020] Figure 2 It is a flowchart of a method for a Java smart contract to access and store data across an SQL contract provided by an embodiment of the present application;

[0021] Figure 3 It is a schematic structural diagram of a data processing device in a blockchain provided by an embodiment of the present application;

[0022] Figure 4 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0023] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some but not all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the protection scope of the present application.

[0024] The following disclosure provides many different embodiments or examples for implementing different structures of the present invention. To simplify the disclosure of the present invention, components and settings of specific examples are described below. Of course, they are only examples and are not intended to limit the present invention. In addition, the present invention may repeat reference numerals and / or letters in different examples. Such repetition is for the purpose of simplification and clarity and does not itself indicate the relationship between the various embodiments and / or settings discussed.

[0025] To solve the problem in the related art that when reading and writing data in a blockchain ledger in the form of key-value pairs through smart contract code, the data operations in the blockchain are relatively cumbersome, the present application provides a data processing method in a blockchain, as Figure 1 shown, the steps of the method include:

[0026] Step 101, when receiving an SQL operation request, parsing the SQL operation request through a Java virtual machine and packaging the parsing result into a cross-contract request object; wherein, the Java virtual machine provides an execution environment for Java contracts;

[0027] The contract in the embodiments of the present application refers to a smart contract in a blockchain. A smart contract is a piece of code that can be deployed and executed in a blockchain network environment. The deployment and execution of this piece of code can be presented in the form of transactions in the blockchain network, and its deployment and execution results can be consensus across the network along with the transactions.

[0028] In addition, in the embodiments of the present application, when writing a Java contract, follow the Java Database Connectivity (JDBC) operation mode, and use standard interfaces such as Connection, PreparedStatement, and ResultSet to perform SQL queries, insertions, updates, and deletions. These operations do not directly access the local database, but communicate with the SQL contract execution engine on the underlying blockchain through the Java virtual machine, so as to achieve cross-contract data operations.

[0029] Step 102: Verify the Java virtual machine. If the verification passes, send the cross - contract request object to the SQL contract execution engine through the Java virtual machine;

[0030] In the embodiment of the present application, the verification of the Java virtual machine is to ensure that the data for cross - contract communication is secure and consistent during cross - contract communication.

[0031] Step 103: After the SQL contract execution engine receives the cross - contract request, operate on the ledger data on the blockchain based on the cross - contract request, return the operation result to the Java virtual machine, and convert the operation result into an operable result set in the Java virtual machine based on the Java virtual machine.

[0032] It can be seen that after the SQL contract execution engine receives the cross - contract request, it is responsible for actually operating on the on - chain ledger data; the engine will execute corresponding database operations according to the SQL statements and parameters in the request object and return the result to the cross - contract communication module, thereby realizing cross - contract communication.

[0033] Through the above steps 101 to 103, when receiving an SQL operation request, the SQL operation request is parsed through the Java virtual machine, and the parsed result is packaged into a cross - contract request object; then, the Java virtual machine is verified. If the verification passes, the cross - contract request object is sent to the SQL contract execution engine through the Java virtual machine. After the SQL contract execution engine receives the cross - contract request, it operates on the ledger data on the blockchain based on the cross - contract request, returns the operation result to the Java virtual machine, and converts the operation result into an operable result set in the Java virtual machine based on the Java virtual machine, thereby realizing cross - contract data operations between the Java virtual machine and the SQL contract execution engine. That is, through the embodiment of the present application, developers can operate on ledger data in the form of SQL statements across SQL contracts in Java contracts and utilize the flexibility of Java as a high - level language, so that complex contract logic can be easily written, making data processing operations in the blockchain more convenient and fast.

[0034] In the embodiment of the present application, for the method of parsing the SQL operation request through the Java virtual machine and packaging the parsed result into a cross - contract request object involved in the above step 101, it can further include:

[0035] Step 11: Identify the content in the SQL statement in the SQL operation request through an SQL parser;

[0036] In a specific example, identifying the content in the SQL statement means identifying the operation type (such as SELECT, INSERT, UPDATE, DELETE) in the SQL statement and information such as table names and fields, so that the identified content can be extracted and bound to the parameters in the Java contract later.

[0037] Step 12, extract the content and bind the content to the parameters in the Java contract;

[0038] In a specific example, extract the placeholder (such as?) in the SQL statement and bind it to the actual parameter passed in the Java code. In addition to the placeholder, named parameters, stored procedure parameters, and dynamic template parameters in the SQL statement can also be passed in and bound in the Java code.

[0039] Step 13, package the bound parameters and content into a cross-contract request object, where the cross-contract request object includes the complete information of the SQL operation.

[0040] In the embodiment of the present application, the parsed SQL statement and parameters are packaged into a cross-contract request object, which contains the complete information of the SQL operation and is ready to be passed to the SQL contract execution engine. For example, the SELECT statement in the Java contract will be converted into a cross-contract request object, and the content includes information such as the SQL statement, parameters, and permissions.

[0041] In the embodiment of the present application, in order to ensure the security and consistency of data, it is necessary to verify the Java virtual machine. Based on this, for the method of verifying the Java virtual machine involved in the above step 102, it can further include: verifying the permission of the Java virtual machine to access the SQL contract, and verifying the data consistency of the Java virtual machine through a distributed transaction protocol.

[0042] In this regard, before cross-contract communication, the system will verify whether the caller (i.e., the Java contract) has the permission to access the target SQL contract. The permission control mechanism can include but is not limited to access control list (ACL), role verification, etc. In addition, in order to ensure data consistency, the cross-contract communication module needs to support transaction management to avoid data inconsistency problems caused by multi-contract operations. The system can ensure consistency through a distributed transaction protocol (such as the two-phase commit protocol). In addition, due to the certain latency of blockchain operations, an asynchronous processing method can be adopted, sending the request to the SQL contract execution engine and setting a callback mechanism, and returning the result to the Java virtual machine after the SQL operation is completed.

[0043] In the embodiments of the present application, after the SQL contract execution engine receives a cross - contract request, it is responsible for actually operating on the on - chain ledger data. The engine will execute corresponding database operations according to the SQL statements and parameters in the request object, and return the results to the Java virtual machine. Based on this, for the method of operating on the ledger data on the blockchain based on a cross - contract request involved in step 103 above, it can further include:

[0044] Step 21, perform at least one of the following operations on the ledger data on the blockchain based on the SQL statement in the cross - contract request: query, insert, update, delete;

[0045] It can be seen that in a specific example, query, insert, update, or delete operations can be executed according to the incoming SQL statement. Furthermore, the SQL contract execution engine regards the on - chain ledger data as a database table, supporting SQL statements to operate on the on - chain data.

[0046] Step 22, verify the legality of the operation based on the SQL contract execution engine;

[0047] In this regard, the SQL contract execution engine needs to verify the legality of the operation to ensure that the contract operation complies with the on - chain security rules, such as only contracts with specific roles can query or modify data in specific tables.

[0048] Step 23, when the verification passes, obtain the result of the operation execution.

[0049] In this regard, the SQL contract execution engine returns the execution result, such as the query result or whether the operation is successful, to the Java virtual machine.

[0050] In the embodiments of the present application, the execution result returned by the SQL contract execution engine is passed to the Java virtual machine. After receiving the result, the Java virtual machine converts it into a result set that can be operated on in Java. Based on this, for the method of converting the operation result into a result set that can be operated on in the Java virtual machine by the Java virtual machine involved in step 103 above, it can further include:

[0051] Step 31, when the operation result is a query result, convert the query result into a ResultSet object, or return the status of success or failure according to the operation type;

[0052] Step 32, when the operation result is the result of an update operation, an insert operation, or a delete operation, convert the operation result into the number of affected rows in the contract or the status code of whether the operation is successful.

[0053] Through the above steps 31 and 32, the query result can be converted into a ResultSet object, or the success or failure status can be returned according to the operation type. If it is an operation such as update, insert, or delete, the result will include the number of affected rows or the status code indicating whether the operation is successful.

[0054] In the embodiments of the present application, during the cross - contract call process, if any error occurs (such as insufficient permissions, data consistency errors, SQL execution failures, etc.), the system will use a rollback mechanism to revoke the executed operations to ensure the consistency of the ledger data. Based on this, the method of the embodiments of the present application further includes:

[0055] Step 41, when the execution of the SQL statement fails in the Java virtual machine, handle the failed operation through an exception - catching mechanism and perform a transaction rollback to revoke the failed operation, or use a distributed transaction protocol for global rollback to ensure the consistency of all participating contract data.

[0056] It can be seen that for this Java contract layer rollback: when the SQL statement execution fails, the Java contract virtual machine will handle the error through an exception - catching mechanism and perform a transaction rollback to revoke the previous operation if necessary. For cross - contract rollback: in a cross - contract transaction, if the execution of a certain contract fails, the system will use a distributed transaction protocol (such as two - phase commit) for global rollback to ensure the consistency of all participating contract data.

[0057] The following illustrates the present application by combining with the specific implementation manners of the embodiments of the present application. The specific implementation manner provides a method for a Java smart contract to access and store data across SQL contracts. This method realizes cross - contract data access and storage of SQL contracts based on Java contracts. By enhancing the capabilities of the Java virtual machine, it allows developers to operate on ledger data in the form of SQL statements across SQL contracts in Java contracts, and utilize the flexibility of Java as a high - level language, so that complex contract logic can be easily written. To lower the development threshold, the operation mode in the embodiments of the present application is consistent with the traditional JDBC operation, thus greatly simplifying the development process and enhancing the functionality and usability of the system. As Figure 2 shown, the method steps in the specific implementation manner include:

[0058] Step 201, the Java virtual machine executes the contract;

[0059] When developers write Java contracts, they follow the traditional JDBC operation mode and use standard interfaces such as Connection, PreparedStatement, and ResultSet to perform SQL queries, insertions, updates, and deletions. The difference with these operations is that they do not directly access the local database, but communicate with the SQL contract execution engine on the underlying blockchain through the Java contract virtual machine.

[0060] Step 202, the Java virtual machine performs cross-SQL contract parameter parsing;

[0061] Specifically, it includes SQL syntax parsing: through the SQL parser, identify the operation types (such as SELECT, INSERT, UPDATE, DELETE) in the SQL statement, as well as information such as table names and fields. And parameter extraction and binding: extract the placeholders (such as?) in the SQL statement and bind the actual parameters passed in by the developer in the Java code.

[0062] Step 203, Java initiates cross-SQL contract communication;

[0063] Step 204, the SQL execution engine listens for cross-contract calls;

[0064] Step 205, the SQL execution engine performs SQL parsing;

[0065] Specifically, according to the incoming SQL statement, perform query, insertion, update, or deletion operations. The SQL execution engine regards the ledger data on the chain as a database table and supports SQL statements to operate on the data on the chain. The SQL execution engine needs to verify the legality of the operations to ensure that the operations of the contract comply with the security rules on the chain, such as only contracts with specific roles can query or modify the data of specific tables.

[0066] Step 206, the SQL execution engine returns the execution result to the Java virtual machine and continues to listen;

[0067] Step 207, the Java virtual machine processes the returned result;

[0068] In this regard, after receiving the result, the Java virtual machine converts it into a result set that can be operated on in Java. For example, it converts the query result into a ResultSet object, or returns the status of success or failure according to the operation type. Developers can further process these results in the Java contract, perform logical judgments or other operations; if it is an update, insertion, or deletion operation, the result will include the number of affected rows or the status code indicating whether the operation was successful.

[0069] Step 208, the Java virtual machine continues to execute.

[0070] Through the above steps 201 to 208, the SQL contract is combined with the Java contract, breaking the limitations of existing Java contracts, supporting data operations across SQL contracts, allowing developers to use SQL statements in Java contracts for complex queries and transaction operations, and enhancing the functions of Java smart contracts. In addition, by simulating the operation mode of traditional JDBC, developers can use familiar SQL statements for on-chain data operations, reducing the learning cost and development time. Developers can write complex smart contracts without having to deeply understand the details of the blockchain underlying layer, thus greatly improving the development efficiency. In addition, by combining Java smart contracts with SQL contracts, developers can more easily migrate existing database logic to blockchain applications, avoiding huge changes to traditional relational databases.

[0071] Corresponding to the above Figure 1 , the embodiment of the present application further provides a data processing device in a blockchain, such as Figure 3 shown. The device includes:

[0072] A first processing module 302, configured to, when receiving an SQL operation request, parse the SQL operation request through a Java virtual machine and package the parsing result into a cross-contract request object; wherein, the Java virtual machine provides an execution environment for the Java contract;

[0073] A second processing module 304, configured to verify the Java virtual machine, and when the verification is passed, send the cross-contract request object to the SQL contract execution engine through the Java virtual machine;

[0074] A third processing module 306, configured to, after the SQL contract execution engine receives the cross-contract request, operate on the ledger data on the blockchain based on the cross-contract request, return the operation result to the Java virtual machine, and convert the operation result into a result set operable in the Java virtual machine based on the Java virtual machine.

[0075] Through the device according to the embodiments of the present application, when receiving an SQL operation request, the SQL operation request is parsed by the Java virtual machine, and the parsing result is packaged into a cross-contract request object; then, the Java virtual machine is verified, and when the verification is passed, the cross-contract request object is sent to the SQL contract execution engine by the Java virtual machine. After the SQL contract execution engine receives the cross-contract request, it operates on the ledger data on the blockchain based on the cross-contract request, and returns the operation result to the Java virtual machine, and converts the operation result into a result set that can be operated on in the Java virtual machine based on the Java virtual machine, thereby realizing cross-contract data operation between the Java virtual machine and the SQL contract execution engine. That is, through the embodiments of the present application, developers can operate on the ledger data in the form of SQL statements across SQL contracts in the Java contract, and utilize the flexibility of Java as a high-level language, so that complex contract logic can be easily written, making data processing operations in the blockchain more convenient and fast.

[0076] In an alternative implementation manner of the embodiments of the present application, the first processing module in the embodiments of the present application may include: an identification unit for identifying the content in the SQL statement in the SQL operation request through an SQL parser; a first processing unit for extracting the content and binding the content to the parameters in the Java contract; a second processing unit for packaging the bound parameters and content into a cross-contract request object, where the cross-contract request object includes the complete information of the SQL operation.

[0077] In an alternative implementation manner of the embodiments of the present application, the second processing module in the embodiments of the present application may further include: a first verification unit for verifying the permission of the Java virtual machine to access the SQL contract, and verifying the data consistency of the Java virtual machine through a distributed transaction protocol.

[0078] In an alternative implementation manner of the embodiments of the present application, the third processing module in the embodiments of the present application may further include: a third processing unit for performing at least one of the following operations on the ledger data on the blockchain based on the SQL statement in the cross-contract request: querying, inserting, updating, deleting; a second verification unit for verifying the legality of the operation based on the SQL contract execution engine; an obtaining unit for obtaining the result of the operation execution when the verification is passed.

[0079] In an alternative implementation of the embodiment of the present application, the third processing module in the embodiment of the present application may further include: a fourth processing unit, configured to convert the query result into a ResultSet object or return a status indicating success or failure according to the operation type when the operation result is a query result; a fifth processing unit, configured to convert the operation result into the number of affected rows in the contract or a status code indicating whether the operation is successful when the operation result is a result of an update operation, an insert operation, or a delete operation.

[0080] In an alternative implementation of the embodiment of the present application, the device in the embodiment of the present application further includes: a fourth processing module, configured to, when the Java virtual machine fails to execute an SQL statement, process the failed operation through an exception capture mechanism and perform a transaction rollback to revoke the failed operation, or use a distributed transaction protocol for global rollback to ensure the consistency of all participating contract data.

[0081] As Figure 4 shown, the embodiment of the present application provides an electronic device, including a processor 411, a communication interface 412, a memory 413, and a communication bus 414. Among them, the processor 411, the communication interface 412, and the memory 413 complete mutual communication through the communication bus 414. The memory 413 is used to store a computer program.

[0082] In an embodiment of the present application, when the processor 411 executes the program stored on the memory 413, it implements the data processing method in the blockchain provided by any one of the foregoing method embodiments, and the functions it performs are similar, which will not be elaborated here.

[0083] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the data processing method in the blockchain provided by any one of the foregoing method embodiments.

[0084] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0085] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0086] It should be understood that the terms used herein are for the purpose of describing specific example embodiments only and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" as used herein may also include the plural forms. The terms "comprising", "including", "containing", and "having" are inclusive and thus specify the presence of the stated features, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and / or their combinations. The method steps, processes, and operations described herein are not to be construed as necessarily requiring them to be performed in the particular order described or illustrated, unless the order of performance is explicitly stated. It should also be understood that additional or alternative steps may be used.

[0087] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to these embodiments shown herein, but rather will conform to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for processing data in a blockchain, characterized in that: include: When receiving an SQL operation request, the SQL operation request is parsed by a Java virtual machine, and the parsing result is packaged as a cross-contract request object; wherein the Java virtual machine provides an execution environment for the Java contract; Verifying the Java virtual machine, and if the verification passes, sending the cross-contract request object to the SQL contract execution engine through the Java virtual machine; After the SQL contract execution engine receives the cross-contract request, it operates on the ledger data on the blockchain based on the cross-contract request, returns the operation result to the Java virtual machine, and converts the operation result into an operable result set in the Java virtual machine based on the Java virtual machine.

2. The method according to claim 1, characterized in that When receiving an SQL operation request, the SQL operation request is parsed by a Java virtual machine, and the parsing result is packaged into a cross-contract request object including: Identify the content of the SQL statement in the SQL operation request by using a SQL parser; Extracting the content and binding the content to the parameters in the Java contract; The bound parameters and content are packaged into the cross-contract request object, wherein the cross-contract request object includes complete information of the SQL operation.

3. The method according to claim 1, characterized in that Verifying the Java virtual machine includes: The Java virtual machine's permission to access the SQL contract is verified, and the data consistency of the Java virtual machine is verified through a distributed transaction protocol.

4. The method according to claim 1, characterized in that: The ledger data on the blockchain is operated based on the cross-contract request, including: Perform at least one of the following operations on the ledger data on the blockchain based on the SQL statement in the cross-contract request: query, insert, update, delete; Verifying the legality of the operation based on the SQL contract execution engine; If the verification passes, the result of the operation execution is obtained.

5. The method according to claim 1, characterized in that Converting the operation result into a result set operable in the Java virtual machine based on the Java virtual machine includes: In the case where the operation result is a query result, converting the query result into a ResultSet object, or returning a success or failure status according to the operation type; In the case where the operation result is the result of an update operation, an insert operation, or a delete operation, the operation result is converted into the number of rows affected in the contract or a status code indicating whether the operation is successful.

6. The method according to claim 1, characterized in that The method further comprises: In the event that the Java virtual machine fails to execute the SQL statement, the failed operation is handled through an exception capture mechanism, and a transaction rollback is performed to undo the failed operation, or a global rollback is performed using a distributed transaction protocol to ensure consistency of data among all participating contracts.

7. A data processing device in a blockchain, characterized in that: include: A first processing module is used to parse the SQL operation request through a Java virtual machine when receiving the SQL operation request, and package the parsing result into a cross-contract request object; wherein the Java virtual machine provides an execution environment for the Java contract; A second processing module is used to verify the Java virtual machine, and if the verification passes, send the cross-contract request object to the SQL contract execution engine through the Java virtual machine; The third processing module is used to operate the ledger data on the blockchain based on the cross-contract request after the SQL contract execution engine receives the cross-contract request, return the operation result to the Java virtual machine, and convert the operation result into an operable result set in the Java virtual machine based on the Java virtual machine.

8. The device according to claim 7, characterized in that The first processing module includes: An identification unit, used for identifying the content of the SQL statement in the SQL operation request through a SQL parser; A first processing unit, configured to extract the content and bind the content to parameters in the Java contract; The second processing unit is used to package the bound parameters and content into the cross-contract request object, wherein the cross-contract request object includes complete information of the SQL operation.

9. An electronic device comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor coupled to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to execute the data processing method in the blockchain according to any one of claims 1 to 6.

10. A computer storage medium storing computer executable instructions, wherein the computer executable instructions are used to execute the data processing method in the blockchain described in any one of claims 1 to 6.