Package com.mysql.ndbjtie.ndbapi

Examples of com.mysql.ndbjtie.ndbapi.NdbOperation


    }

    protected void ndbjtieInsert(int c0) {

        // get an insert operation for the table
        NdbOperation op = tx.getNdbOperation(table_t0);
        if (op == null)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
        if (op.insertTuple() != 0)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

        // include exception handling as part of transcoding pattern
        final int i = c0;
        final CharBuffer str = CharBuffer.wrap(Integer.toString(i));
        try {
            // set values; key attribute needs to be set first
            //str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.equal(metaData.getAttr(0), bb) != 0) // key
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(0));

            str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.setValue(metaData.getAttr(1), bb) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(1));

            if (op.setValue(metaData.getAttr(2), i) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            if (op.setValue(metaData.getAttr(3), i) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            // XXX
            if (op.setValue(metaData.getAttr(4), null) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.setValue(metaData.getAttr(5), bb) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(5));

            str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.setValue(metaData.getAttr(6), bb) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(6));

            str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.setValue(metaData.getAttr(7), bb) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(7));

            str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.setValue(metaData.getAttr(8), bb) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(8));

            // XXX
            if (op.setValue(metaData.getAttr(9), null) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            if (op.setValue(metaData.getAttr(10), null) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            if (op.setValue(metaData.getAttr(11), null) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            if (op.setValue(metaData.getAttr(12), null) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            if (op.setValue(metaData.getAttr(13), null) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            if (op.setValue(metaData.getAttr(14), null) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
        } catch (CharacterCodingException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here


        driver.finish(name);
    }

    protected void ndbjtieLookup(int c0) {
        // get a lookup operation for the table
        NdbOperation op = tx.getNdbOperation(table_t0);
        if (op == null)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
        if (op.readTuple(ndbOpLockMode) != 0)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

        int p = bb.position();

        // include exception handling as part of transcoding pattern
        final CharBuffer str = CharBuffer.wrap(Integer.toString(c0));
        try {
            // set values; key attribute needs to be set first
            //str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.equal(metaData.getAttr(0), bb) != 0) // key
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(p += metaData.getColumnWidth(0));
        } catch (CharacterCodingException e) {
            throw new RuntimeException(e);
        }

        // get attributes (not readable until after commit)
        for(int i = 1; i < metaData.getColumnCount(); i++) {
            if (op.getValue(metaData.getAttr(i), bb) == null)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(p += metaData.getColumnWidth(i));
        }
    }
View Full Code Here

        final CharBuffer str0 = CharBuffer.wrap(Integer.toString(c0));
        final int r = -c0;
        final CharBuffer str1 = CharBuffer.wrap(Integer.toString(r));

        // get an update operation for the table
        NdbOperation op = tx.getNdbOperation(table_t0);
        if (op == null)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
        if (op.updateTuple() != 0)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

        // include exception handling as part of transcoding pattern
        try {
            // set values; key attribute needs to be set first
            //str0.rewind();
            ndbjtieTranscode(bb, str0);
            if (op.equal(metaData.getAttr(0), bb) != 0) // key
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(0));

            //str1.rewind();
            ndbjtieTranscode(bb, str1);
            if (op.setValue(metaData.getAttr(1), bb) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(1));

            if (op.setValue(metaData.getAttr(2), r) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            if (op.setValue(metaData.getAttr(3), r) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

            for(int i = 5; i < metaData.getColumnCount(); i++) {
            str1.rewind();
            ndbjtieTranscode(bb, str1);
            if (op.setValue(metaData.getAttr(i), bb) != 0)
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(bb.position() + metaData.getColumnWidth(i));
            }

        } catch (CharacterCodingException e) {
View Full Code Here

        driver.finish(name);
    }

    protected void ndbjtieDelete(int c0) {
        // get a delete operation for the table
        NdbOperation op = tx.getNdbOperation(table_t0);
        if (op == null)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
        if (op.deleteTuple() != 0)
            throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));

        int p = bb.position();

        // include exception handling as part of transcoding pattern
        final int i = c0;
        final CharBuffer str = CharBuffer.wrap(Integer.toString(c0));
        try {
            // set values; key attribute needs to be set first
            //str.rewind();
            ndbjtieTranscode(bb, str);
            if (op.equal(metaData.getAttr(0), bb) != 0) // key
                throw new RuntimeException(TwsUtils.toStr(tx.getNdbError()));
            bb.position(p += metaData.getColumnWidth(0));
        } catch (CharacterCodingException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

    protected void setByPK(TableConst table, int from, int to,
                           boolean batch) {
        beginTransaction();
        for (int i = from; i <= to; i++) {
            // get an update operation for the table
            NdbOperation op = tx.getNdbOperation(table);
            if (op == null)
                throw new RuntimeException(toStr(tx.getNdbError()));
            if (op.updateTuple() != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));

            // set key attribute
            if (op.equal(model.attr_id, i) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));

            // set values
            if (op.setValue(model.attr_cint, i) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));
            if (op.setValue(model.attr_clong, (long)i) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));
            if (op.setValue(model.attr_cfloat, (float)i) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));
            if (op.setValue(model.attr_cdouble, (double)i) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));

            // execute the operation now if in non-batching mode
            if (!batch)
                executeOperations();
View Full Code Here

        cab.order(ByteOrder.nativeOrder());

        beginTransaction();
        for (int i = 0, j = from; i < count; i++, j++) {
            // get a read operation for the table
            NdbOperation op = tx.getNdbOperation(table);
            if (op == null)
                throw new RuntimeException(toStr(tx.getNdbError()));
            if (op.readTuple(NdbOperation.LockMode.LM_CommittedRead) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));

            // set key attribute
            if (op.equal(model.attr_id, j) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));

            // get attributes (not readable until after commit)
            fetchCommonAttributes(cab, op);
View Full Code Here

        final CommonAB_RA[] cab_ra = new CommonAB_RA[count];

        beginTransaction();
        for (int i = 0, j = from; i < count; i++, j++) {
            // get a read operation for the table
            NdbOperation op = tx.getNdbOperation(table);
            if (op == null)
                throw new RuntimeException(toStr(tx.getNdbError()));
            if (op.readTuple(NdbOperation.LockMode.LM_CommittedRead) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));

            // set key attribute
            if (op.equal(model.attr_id, j) != 0)
                throw new RuntimeException(toStr(tx.getNdbError()));

            // get attributes (not readable until after commit)
            final CommonAB_RA c = new CommonAB_RA();
            //if ((c.id = op.getValue(model.attr_id, null)) == null)
View Full Code Here

    public Operation getDeleteOperation(Table storeTable) {
        enlist();
        TableConst ndbTable = ndbDictionary.getTable(storeTable.getName());
        handleError(ndbTable, ndbDictionary);
        NdbOperation ndbOperation = ndbTransaction.getNdbOperation(ndbTable);
        handleError(ndbOperation, ndbTransaction);
        int returnCode = ndbOperation.deleteTuple();
        handleError(returnCode, ndbTransaction);
        if (logger.isTraceEnabled()) logger.trace("Table: " + storeTable.getName());;
        return new OperationImpl(ndbOperation, this);
    }
View Full Code Here

    public Operation getInsertOperation(Table storeTable) {
        enlist();
        TableConst ndbTable = ndbDictionary.getTable(storeTable.getName());
        handleError(ndbTable, ndbDictionary);
        NdbOperation ndbOperation = ndbTransaction.getNdbOperation(ndbTable);
        handleError(ndbOperation, ndbTransaction);
        int returnCode = ndbOperation.insertTuple();
        handleError(returnCode, ndbTransaction);
        if (logger.isTraceEnabled()) logger.trace("Table: " + storeTable.getName());
        return new OperationImpl(ndbOperation, this);
    }
View Full Code Here

    public Operation getSelectOperation(Table storeTable) {
        enlist();
        TableConst ndbTable = ndbDictionary.getTable(storeTable.getName());
        handleError(ndbTable, ndbDictionary);
        NdbOperation ndbOperation = ndbTransaction.getNdbOperation(ndbTable);
        handleError(ndbOperation, ndbTransaction);
        int lockMode = findLockMode;
        int returnCode = ndbOperation.readTuple(lockMode);
        handleError(returnCode, ndbTransaction);
        if (logger.isTraceEnabled()) logger.trace("Table: " + storeTable.getName());
        return new OperationImpl(storeTable, ndbOperation, this);
    }
View Full Code Here

TOP

Related Classes of com.mysql.ndbjtie.ndbapi.NdbOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.