Package org.tmatesoft.sqljet.core

Examples of org.tmatesoft.sqljet.core.SqlJetException


     */
    private Object[] getValuesRowForInsert(Object... values) throws SqlJetException {
        final Object[] row = new Object[tableDef.getColumns().size()];
        if (null != values && values.length != 0) {
            if (values.length > row.length) {
                throw new SqlJetException(SqlJetErrorCode.MISUSE, "Values count is more than columns in table");
            }
            final Object[] a = SqlJetUtility.adjustNumberTypes(values);
            System.arraycopy(a, 0, row, 0, a.length);
        }
        return row;
View Full Code Here


    private Object[] getValuesRowForUpdate(Object... values) throws SqlJetException {
        final Object[] row = new Object[tableDef.getColumns().size()];
        System.arraycopy(getValues(), 0, row, 0, row.length);
        if (null != values && values.length != 0) {
            if (values.length > row.length) {
                throw new SqlJetException(SqlJetErrorCode.MISUSE, "Values count is more than columns in table");
            }
            final Object[] a = SqlJetUtility.adjustNumberTypes(values);
            System.arraycopy(a, 0, row, 0, a.length);
        }
        return row;
View Full Code Here

     */
    private long getRowIdForRow(final Object[] row, boolean required) throws SqlJetException {
        if (tableDef.isRowIdPrimaryKey()) {
            final int primaryKeyColumnNumber = tableDef.getColumnNumber(tableDef.getRowIdPrimaryKeyColumnName());
            if (primaryKeyColumnNumber == -1 || primaryKeyColumnNumber >= row.length)
                throw new SqlJetException(SqlJetErrorCode.ERROR);
            final Object rowIdParam = row[primaryKeyColumnNumber];
            if (null != rowIdParam) {
                if (rowIdParam instanceof Long) {
                    long rowId = (Long) rowIdParam;
                    if (rowId > 0) {
                        return rowId;
                    } else {
                        throw new SqlJetException(SqlJetErrorCode.MISUSE,
                                "INTEGER PRIMARY KEY column must be more than zero");
                    }
                } else {
                    throw new SqlJetException(SqlJetErrorCode.MISUSE,
                            "INTEGER PRIMARY KEY column must have only integer value");
                }
            }
        }
        if (required) {
View Full Code Here

        if (!tableDef.isRowIdPrimaryKey()) {
            pData = SqlJetBtreeRecord.getRecord(encoding, row).getRawRecord();
        } else {
            final int primaryKeyColumnNumber = tableDef.getColumnNumber(tableDef.getRowIdPrimaryKeyColumnName());
            if (primaryKeyColumnNumber == -1 || primaryKeyColumnNumber >= row.length)
                throw new SqlJetException(SqlJetErrorCode.ERROR);
            row[primaryKeyColumnNumber] = null;
            pData = SqlJetBtreeRecord.getRecord(encoding, row).getRawRecord();
            row[primaryKeyColumnNumber] = rowId;
        }
        if (doActionWithIndexes(Action.INSERT, onConflict, rowId, row)) {
View Full Code Here

     */
    public void update(SqlJetConflictAction onConflict, long rowId, Object... values) throws SqlJetException {
        lock();
        try {
            if (rowId <= 0 || !goToRow(rowId))
                throw new SqlJetException(SqlJetErrorCode.MISUSE, "Incorrect rowId value: " + rowId);
            final Object[] row = getValuesRowForUpdate(values);
            if (rowId < 1) {
                rowId = getRowIdForRow(row, false);
            }
            doUpdate(onConflict, rowId, row);
View Full Code Here

     */
    public void updateCurrent(SqlJetConflictAction onConflict, Object... values) throws SqlJetException {
        lock();
        try {
            if (eof())
                throw new SqlJetException(SqlJetErrorCode.MISUSE, "No current record");
            final Object[] row = getValuesRowForUpdate(values);
            final long rowId = getRowIdForRow(row, false);
            doUpdate(onConflict, rowId, row);
        } finally {
            unlock();
View Full Code Here

    public long updateWithRowId(SqlJetConflictAction onConflict, long rowId, long newRowId, Object... values)
            throws SqlJetException {
        lock();
        try {
            if (rowId <= 0 || !goToRow(rowId))
                throw new SqlJetException(SqlJetErrorCode.MISUSE, "Incorrect rowId value: " + rowId);
            final Object[] row = getValuesRowForUpdate(values);
            if (newRowId < 1) {
                newRowId = getRowIdForRow(row, false);
            }
            doUpdate(onConflict, newRowId > 0 ? newRowId : rowId, row);
View Full Code Here

    public long updateCurrentWithRowId(SqlJetConflictAction onConflict, long newRowId, Object... values)
            throws SqlJetException {
        lock();
        try {
            if (eof())
                throw new SqlJetException(SqlJetErrorCode.MISUSE, "No current record");
            final Object[] row = getValuesRowForUpdate(values);
            if (newRowId < 1) {
                newRowId = getRowIdForRow(row, false);
            }
            doUpdate(onConflict, newRowId, getValuesRowForUpdate(values));
View Full Code Here

        if (!tableDef.isRowIdPrimaryKey()) {
            pData = SqlJetBtreeRecord.getRecord(encoding, rowCompleted).getRawRecord();
        } else {
            final int primaryKeyColumnNumber = tableDef.getColumnNumber(tableDef.getRowIdPrimaryKeyColumnName());
            if (primaryKeyColumnNumber == -1 || primaryKeyColumnNumber >= rowCompleted.length)
                throw new SqlJetException(SqlJetErrorCode.ERROR);
            rowCompleted[primaryKeyColumnNumber] = null;
            pData = SqlJetBtreeRecord.getRecord(encoding, rowCompleted).getRawRecord();
            rowCompleted[primaryKeyColumnNumber] = newRowId;
        }
        if (doActionWithIndexes(Action.UPDATE, onConflict, newRowId, rowCompleted)) {
View Full Code Here

     */
    public void delete(long rowId) throws SqlJetException {
        lock();
        try {
            if (rowId <= 0 || !goToRow(rowId))
                throw new SqlJetException(SqlJetErrorCode.MISUSE, "Incorrect rowId value: " + rowId);
            doDelete();
        } finally {
            unlock();
        }
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.sqljet.core.SqlJetException

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.