Search in sources :

Example 41 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class EmbedCallableStatement method executeStatement.

protected final boolean executeStatement(Activation a, boolean executeQuery, boolean executeUpdate) throws SQLException {
    // need this additional check (it's also in the super.executeStatement
    // to ensure we have an activation for the getParams
    checkExecStatus();
    synchronized (getConnectionSynchronization()) {
        wasNull = false;
        // right object to hold the return value from the CallableStatement.
        try {
            getParms().validate();
        } catch (StandardException e) {
            throw EmbedResultSet.noStateChangeException(e);
        }
        /* KLUDGE - ? = CALL ... returns a ResultSet().  We
			 * need executeUpdate to be false in that case.
			 */
        boolean execResult = super.executeStatement(a, executeQuery, (executeUpdate && (!hasReturnOutputParameter)));
        // Fetch the getParms into a local variable now because the
        // activation associated with a CallableStatement at this
        // point(after the executStatement) is the current activation.
        // We can now safely stuff the return value of the
        // CallableStatement into the following ParameterValueSet object.
        ParameterValueSet pvs = getParms();
        /*
			** If we have a return parameter, then we
			** consume it from the returned ResultSet
			** reset the ResultSet set to null.
			*/
        if (hasReturnOutputParameter) {
            if (SanityManager.DEBUG) {
                SanityManager.ASSERT(results != null, "null results even though we are supposed to have a return parameter");
            }
            boolean gotRow = results.next();
            if (SanityManager.DEBUG) {
                SanityManager.ASSERT(gotRow, "the return resultSet didn't have any rows");
            }
            try {
                DataValueDescriptor returnValue = pvs.getReturnValueForSet();
                returnValue.setValueFromResultSet(results, 1, true);
            } catch (StandardException e) {
                throw EmbedResultSet.noStateChangeException(e);
            } finally {
                results.close();
                results = null;
            }
            // This is a form of ? = CALL which current is not a procedure call.
            // Thus there cannot be any user result sets, so return false. execResult
            // is set to true since a result set was returned, for the return parameter.
            execResult = false;
        }
        return execResult;
    }
}
Also used : ParameterValueSet(org.apache.derby.iapi.sql.ParameterValueSet) StandardException(org.apache.derby.shared.common.error.StandardException) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor)

Example 42 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class EmbedCallableStatement method getTime.

/**
 * @see CallableStatement#getTime
 * @exception SQLException NoOutputParameters thrown.
 */
public Time getTime(int parameterIndex, Calendar cal) throws SQLException {
    checkStatus();
    try {
        Time v = getParms().getParameterForGet(parameterIndex - 1).getTime(cal);
        wasNull = (v == null);
        return v;
    } catch (StandardException e) {
        throw EmbedResultSet.noStateChangeException(e);
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) Time(java.sql.Time)

Example 43 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class EmbedCallableStatement method getFloat.

/**
 * @see CallableStatement#getFloat
 * @exception SQLException NoOutputParameters thrown.
 */
public float getFloat(int parameterIndex) throws SQLException {
    checkStatus();
    try {
        DataValueDescriptor param = getParms().getParameterForGet(parameterIndex - 1);
        float v = param.getFloat();
        wasNull = (v == 0.0) && param.isNull();
        return v;
    } catch (StandardException e) {
        throw EmbedResultSet.noStateChangeException(e);
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor)

Example 44 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class EmbedCallableStatement method getLong.

/**
 * @see CallableStatement#getLong
 * @exception SQLException NoOutputParameters thrown.
 */
public long getLong(int parameterIndex) throws SQLException {
    checkStatus();
    try {
        DataValueDescriptor param = getParms().getParameterForGet(parameterIndex - 1);
        long v = param.getLong();
        wasNull = (v == 0L) && param.isNull();
        return v;
    } catch (StandardException e) {
        throw EmbedResultSet.noStateChangeException(e);
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor)

Example 45 with StandardException

use of org.apache.derby.shared.common.error.StandardException in project derby by apache.

the class DataDictionaryImpl method debugGenerateInfo.

private void debugGenerateInfo(StringBuffer strbuf, TransactionController tc, ConglomerateController heapCC, TabInfoImpl ti, int indexId) {
    if (SanityManager.DEBUG) {
        try {
            strbuf.append("\nadditional information: ");
            // print the lock table
            // will get a NullPointerException if lcc doesn't yet exist e.g. at boot time
            LanguageConnectionContext lcc = (LanguageConnectionContext) getContext(LanguageConnectionContext.CONTEXT_ID);
            if (lcc != null) {
                long currentTime = System.currentTimeMillis();
                // EXCLUDE-START-lockdiag-
                Enumeration lockTable = lockFactory.makeVirtualLockTable();
                String lockTableString = Timeout.buildString(lockTable, currentTime);
                strbuf.append("lock table at time of failure\n\n");
                strbuf.append(lockTableString);
            // EXCLUDE-END-lockdiag-
            }
            // consistency checking etc.
            ConglomerateController btreeCC = tc.openConglomerate(ti.getIndexConglomerate(indexId), false, 0, TransactionController.MODE_RECORD, TransactionController.ISOLATION_REPEATABLE_READ);
            btreeCC.debugConglomerate();
            heapCC.debugConglomerate();
            heapCC.checkConsistency();
            strbuf.append("\nheapCC.checkConsistency() = true");
            ConglomerateController indexCC = tc.openConglomerate(ti.getIndexConglomerate(indexId), false, 0, TransactionController.MODE_TABLE, TransactionController.ISOLATION_REPEATABLE_READ);
            indexCC.checkConsistency();
            strbuf.append("\nindexCC.checkConsistency() = true");
            System.err.println("ASSERT FAILURE: " + strbuf.toString());
            System.out.println("ASSERT FAILURE: " + strbuf.toString());
            SanityManager.DEBUG_PRINT("ASSERT FAILURE", strbuf.toString());
        } catch (StandardException se) {
            strbuf.append("\ngot the following error when doing extra consistency checks:\n" + se.toString());
        }
    }
}
Also used : StandardException(org.apache.derby.shared.common.error.StandardException) Enumeration(java.util.Enumeration) LanguageConnectionContext(org.apache.derby.iapi.sql.conn.LanguageConnectionContext) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController)

Aggregations

StandardException (org.apache.derby.shared.common.error.StandardException)276 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)43 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)37 IOException (java.io.IOException)32 Properties (java.util.Properties)29 RawTransaction (org.apache.derby.iapi.store.raw.xact.RawTransaction)27 TransactionController (org.apache.derby.iapi.store.access.TransactionController)26 ContextManager (org.apache.derby.iapi.services.context.ContextManager)22 RawContainerHandle (org.apache.derby.iapi.store.raw.data.RawContainerHandle)20 SQLException (java.sql.SQLException)17 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)17 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)16 ConglomerateController (org.apache.derby.iapi.store.access.ConglomerateController)12 RowLocation (org.apache.derby.iapi.types.RowLocation)11 SQLLongint (org.apache.derby.iapi.types.SQLLongint)11 StorageFile (org.apache.derby.io.StorageFile)10 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)9 ScanController (org.apache.derby.iapi.store.access.ScanController)9 File (java.io.File)8 LogInstant (org.apache.derby.iapi.store.raw.log.LogInstant)8