Search in sources :

Example 6 with HsqlException

use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.

the class DataFileDefrag method writeTransactionRows.

void writeTransactionRows() {
    for (int i = 0, size = transactionRowLookup.size(); i < size; i++) {
        if (transactionRowLookup.getValue(i) != 0) {
            continue;
        }
        int key = transactionRowLookup.getKey(i);
        try {
            transactionRowLookup.setValue(i, (int) (fileOffset / scale));
            RowInputInterface rowIn = cache.readObject(key);
            fileStreamOut.write(rowIn.getBuffer(), 0, rowIn.getSize());
            fileOffset += rowIn.getSize();
        } catch (HsqlException e) {
        } catch (IOException e) {
        }
    }
}
Also used : RowInputInterface(org.hsqldb_voltpatches.rowio.RowInputInterface) IOException(java.io.IOException) HsqlException(org.hsqldb_voltpatches.HsqlException)

Example 7 with HsqlException

use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.

the class LobManager method createDuplicateLob.

public Result createDuplicateLob(Session session, long lobID) {
    Object[] data = getLobHeader(session, lobID);
    if (data == null) {
        Result.newErrorResult(Error.error(ErrorCode.X_0F502));
    }
    long newLobID = getNewLobID(session);
    Object[] params = new Object[data.length];
    params[0] = Long.valueOf(newLobID);
    params[1] = data[1];
    params[2] = data[2];
    params[3] = data[3];
    Result result = session.executeCompiledStatement(createLob, params);
    if (result.isError()) {
        return result;
    }
    long length = ((Long) data[1]).longValue();
    long byteLength = length;
    int lobType = ((Integer) data[1]).intValue();
    if (lobType == Types.SQL_CLOB) {
        byteLength *= 2;
    }
    int newBlockCount = (int) byteLength / lobBlockSize;
    if (byteLength % lobBlockSize != 0) {
        newBlockCount++;
    }
    createBlockAddresses(session, newLobID, 0, newBlockCount);
    // copy the contents
    int[][] sourceBlocks = getBlockAddresses(session, lobID, 0, Integer.MAX_VALUE);
    int[][] targetBlocks = getBlockAddresses(session, newLobID, 0, Integer.MAX_VALUE);
    try {
        copyBlockSet(sourceBlocks, targetBlocks);
    } catch (HsqlException e) {
        return Result.newErrorResult(e);
    }
    return ResultLob.newLobSetResponse(newLobID, length);
}
Also used : HsqlException(org.hsqldb_voltpatches.HsqlException) Result(org.hsqldb_voltpatches.result.Result)

Example 8 with HsqlException

use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.

the class Log method processScript.

/**
     * Performs all the commands in the .script file.
     */
private void processScript() {
    ScriptReaderBase scr = null;
    try {
        if (database.isFilesInJar() || fa.isStreamElement(scriptFileName)) {
            scr = ScriptReaderBase.newScriptReader(database, scriptFileName, scriptFormat);
            Session session = database.sessionManager.getSysSessionForScript(database);
            scr.readAll(session);
            scr.close();
        }
    } catch (Throwable e) {
        if (scr != null) {
            scr.close();
            if (cache != null) {
                cache.close(false);
            }
            closeAllTextCaches(false);
        }
        database.logger.appLog.logContext(e, null);
        if (e instanceof HsqlException) {
            throw (HsqlException) e;
        } else if (e instanceof IOException) {
            throw Error.error(ErrorCode.FILE_IO_ERROR, e.toString());
        } else if (e instanceof OutOfMemoryError) {
            throw Error.error(ErrorCode.OUT_OF_MEMORY);
        } else {
            throw Error.error(ErrorCode.GENERAL_ERROR, e.toString());
        }
    }
}
Also used : ScriptReaderBase(org.hsqldb_voltpatches.scriptio.ScriptReaderBase) IOException(java.io.IOException) HsqlException(org.hsqldb_voltpatches.HsqlException) Session(org.hsqldb_voltpatches.Session)

Example 9 with HsqlException

use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.

the class JDBCCallableStatement method getObject.

//----------------------------------------------------------------------
// Advanced features:
/**
     * <!-- start generic documentation -->
     *
     * Retrieves the value of the designated parameter as an <code>Object</code>
     * in the Java programming language. If the value is an SQL <code>NULL</code>,
     * the driver returns a Java <code>null</code>.
     * <p>
     * This method returns a Java object whose type corresponds to the JDBC
     * type that was registered for this parameter using the method
     * <code>registerOutParameter</code>.  By registering the target JDBC
     * type as <code>java.sql.Types.OTHER</code>, this method can be used
     * to read database-specific abstract data types.
     *
     * <!-- end generic documentation -->
     *
     * <!-- start release-specific documentation -->
     * <div class="ReleaseSpecificDocumentation">
     * <h3>HSQLDB-Specific Information:</h3> <p>
     *
     * HSQLDB supports this feature. <p>
     *
     * </div>
     * <!-- end release-specific documentation -->
     *
     * @param parameterIndex the first parameter is 1, the second is 2,
     *        and so on
     * @return A <code>java.lang.Object</code> holding the OUT parameter value
     * @exception SQLException if a database access error occurs or
     * this method is called on a closed <code>CallableStatement</code>
     * @see java.sql.Types
     * @see #setObject
     */
public synchronized Object getObject(int parameterIndex) throws SQLException {
    checkGetParameterIndex(parameterIndex);
    Type sourceType = parameterTypes[parameterIndex - 1];
    switch(sourceType.typeCode) {
        case Types.SQL_DATE:
            return getDate(parameterIndex);
        case Types.SQL_TIME:
        case Types.SQL_TIME_WITH_TIME_ZONE:
            return getTime(parameterIndex);
        case Types.SQL_TIMESTAMP:
        case Types.SQL_TIMESTAMP_WITH_TIME_ZONE:
            return getTimestamp(parameterIndex);
        case Types.SQL_BINARY:
        case Types.SQL_VARBINARY:
            return getBytes(parameterIndex);
        case Types.OTHER:
        case Types.JAVA_OBJECT:
            {
                Object o = getColumnInType(parameterIndex, sourceType);
                if (o == null) {
                    return null;
                }
                try {
                    return ((JavaObjectData) o).getObject();
                } catch (HsqlException e) {
                    throw Util.sqlException(e);
                }
            }
        default:
            return getColumnInType(parameterIndex, sourceType);
    }
}
Also used : Type(org.hsqldb_voltpatches.types.Type) SchemaObject(org.hsqldb_voltpatches.SchemaObject) HsqlException(org.hsqldb_voltpatches.HsqlException)

Example 10 with HsqlException

use of org.hsqldb_voltpatches.HsqlException in project voltdb by VoltDB.

the class JDBCConnection method releaseSavepoint.

//#endif JAVA4
/**
     * <!-- start generic documentation -->
     *
     * Removes the specified <code>Savepoint</code> (JDBC4 Clarification:) and subsequent <code>Savepoint</code> objects from the current
     * transaction. Any reference to the savepoint after it have been removed
     * will cause an <code>SQLException</code> to be thrown.
     *
     * <!-- end generic documentation -->
     *
     *
     * <b>HSLQDB Note:</b><p>
     *
     * Previous to JDBC 4, <tt>JDBCSavepoint</tt> objects are valid for the life of
     * the originating <tt>Connection</tt> object and hence can be used
     * interchangably, as long as they have equal savepoint names. <p>
     *
     * When built for JDBC 4, <tt>JDBCConnection</tt> objects invalidate
     * <tt>JDBCSavepoint</tt> objects when auto-commit mode is entered as well
     * as when they are used to successfully release or roll back to a named SQL
     * savepoint.  As per the JDBC 4 standard, when built for JDBC 4, this
     * method throws an <tt>SQLException</tt> when this <tt>Connection</tt>
     * object is currently in auto-commit mode and when an invalidated
     * <tt>JDBCSavepoint</tt> is specified. <p>
     *
     * @param savepoint the <code>Savepoint</code> object to be removed
     * @exception SQLException if a database access error occurs, this
     *  (JDBC4 Clarification:)
     *  method is called on a closed connection or
     *            the given <code>Savepoint</code> object is not a valid
     *            savepoint in the current transaction
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
     * this method
     * @see JDBCSavepoint
     * @see java.sql.Savepoint
     * @since JDK 1.4, HSQLDB 1.7.2
     */
//#ifdef JAVA4
public synchronized void releaseSavepoint(Savepoint savepoint) throws SQLException {
    JDBCSavepoint sp;
    Result req;
    checkClosed();
    if (savepoint == null) {
        throw Util.nullArgument();
    }
    if (!(savepoint instanceof JDBCSavepoint)) {
        String msg = Error.getMessage(ErrorCode.X_3B001);
        throw Util.invalidArgument(msg);
    }
    sp = (JDBCSavepoint) savepoint;
    if (JDBCDatabaseMetaData.JDBC_MAJOR >= 4 && sp.name == null) {
        String msg = Error.getMessage(ErrorCode.X_3B001);
        throw Util.invalidArgument(msg);
    }
    if (this != sp.connection) {
        String msg = Error.getMessage(ErrorCode.X_3B001);
        throw Util.invalidArgument(msg);
    }
    if (JDBCDatabaseMetaData.JDBC_MAJOR >= 4 && getAutoCommit()) {
        sp.name = null;
        sp.connection = null;
        throw Util.sqlException(ErrorCode.X_3B001);
    }
    try {
        sessionProxy.releaseSavepoint(sp.name);
        if (JDBCDatabaseMetaData.JDBC_MAJOR >= 4) {
            sp.connection = null;
            sp.name = null;
        }
    } catch (HsqlException e) {
        throw Util.sqlException(e);
    }
}
Also used : HsqlException(org.hsqldb_voltpatches.HsqlException) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

HsqlException (org.hsqldb_voltpatches.HsqlException)46 SchemaObject (org.hsqldb_voltpatches.SchemaObject)19 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)17 Constraint (org.hsqldb_voltpatches.Constraint)16 Table (org.hsqldb_voltpatches.Table)16 Iterator (org.hsqldb_voltpatches.lib.Iterator)16 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)16 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)16 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)16 TextTable (org.hsqldb_voltpatches.TextTable)14 IOException (java.io.IOException)10 Routine (org.hsqldb_voltpatches.Routine)5 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)5 TriggerDef (org.hsqldb_voltpatches.TriggerDef)4 Grantee (org.hsqldb_voltpatches.rights.Grantee)4 Right (org.hsqldb_voltpatches.rights.Right)4 Type (org.hsqldb_voltpatches.types.Type)4 Row (org.hsqldb_voltpatches.Row)3 Result (org.hsqldb_voltpatches.result.Result)3 BatchUpdateException (java.sql.BatchUpdateException)2