Search in sources :

Example 1 with InsertResultEventResponse

use of org.fisco.bcos.channel.test.contract.TableTest.InsertResultEventResponse in project web3sdk by FISCO-BCOS.

the class TableTestClient method insert.

private static void insert(String[] args, TableTest tabletest) {
    if (args.length == 4) {
        try {
            String name = args[1];
            int item_id = Integer.parseInt(args[2]);
            String item_name = args[3];
            RemoteCall<TransactionReceipt> insert = tabletest.insert(name, BigInteger.valueOf(item_id), item_name);
            TransactionReceipt txReceipt = insert.send();
            List<InsertResultEventResponse> insertResultEvents = tabletest.getInsertResultEvents(txReceipt);
            if (insertResultEvents.size() > 0) {
                for (int i = 0; i < insertResultEvents.size(); i++) {
                    InsertResultEventResponse insertResultEventResponse = insertResultEvents.get(i);
                    logger.info("insertCount = " + insertResultEventResponse.count.intValue());
                    System.out.println("insertCount = " + insertResultEventResponse.count.intValue());
                }
            } else {
                System.out.println("t_test table does not exist.");
            }
        } catch (Exception e) {
            System.out.println("insert transaction is abnormal, please check the environment");
        }
    } else {
        System.out.println("\nPlease enter as follow example:\n 1 1 insert fruit 1 apple");
    }
}
Also used : TransactionReceipt(org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt) InsertResultEventResponse(org.fisco.bcos.channel.test.contract.TableTest.InsertResultEventResponse) TransactionException(org.fisco.bcos.web3j.protocol.exceptions.TransactionException)

Aggregations

InsertResultEventResponse (org.fisco.bcos.channel.test.contract.TableTest.InsertResultEventResponse)1 TransactionReceipt (org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt)1 TransactionException (org.fisco.bcos.web3j.protocol.exceptions.TransactionException)1