/** * @see CallableStatement#registerOutParameter * @exception SQLException NoOutputParameters thrown. */ public final void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { checkStatus(); try { getParms().registerOutParameter(parameterIndex - 1, sqlType, -1); } catch (StandardException e) { throw EmbedResultSet.noStateChangeException(e); } }
public void setRowId(int parameterIndex, RowId x) throws SQLException { checkStatus(); try { /* JDBC is one-based, DBMS is zero-based */ getParms().getParameterForSet(parameterIndex - 1).setValue(x); } catch (Throwable t) { throw EmbedResultSet.noStateChangeException(t); } }
/** * @see CallableStatement#getTimestamp * @exception SQLException NoOutputParameters thrown. */ public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException { checkStatus(); try { Timestamp v = getParms().getParameterForGet(parameterIndex - 1).getTimestamp(cal); wasNull = (v == null); return v; } catch (StandardException e) { throw EmbedResultSet.noStateChangeException(e); } }
/** * @see CallableStatement#getBytes * @exception SQLException NoOutputParameters thrown. */ public byte[] getBytes(int parameterIndex) throws SQLException { checkStatus(); try { byte[] v = getParms().getParameterForGet(parameterIndex - 1).getBytes(); wasNull = (v == null); return v; } catch (StandardException e) { throw EmbedResultSet.noStateChangeException(e); } }
/** * @see CallableStatement#getDouble * @exception SQLException NoOutputParameters thrown. */ public double getDouble(int parameterIndex) throws SQLException { checkStatus(); try { DataValueDescriptor param = getParms().getParameterForGet(parameterIndex - 1); double v = param.getDouble(); wasNull = (v == 0.0) && param.isNull(); return v; } catch (StandardException e) { throw EmbedResultSet.noStateChangeException(e); } }
/** * @see CallableStatement#getShort * @exception SQLException NoOutputParameters thrown. */ public short getShort(int parameterIndex) throws SQLException { checkStatus(); try { DataValueDescriptor param = getParms().getParameterForGet(parameterIndex - 1); short s = param.getShort(); wasNull = (s == 0) && param.isNull(); return s; } catch (StandardException e) { throw EmbedResultSet.noStateChangeException(e); } }
/** * @see CallableStatement#registerOutParameter * @exception SQLException NoOutputParameters thrown. */ public final void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException { checkStatus(); if (scale < 0) throw newSQLException(SQLState.BAD_SCALE_VALUE, new Integer(scale)); try { getParms().registerOutParameter(parameterIndex - 1, sqlType, scale); } catch (StandardException e) { throw EmbedResultSet.noStateChangeException(e); } }
/** * JDBC 2.0 * * <p>Get the value of a NUMERIC parameter as a java.math.BigDecimal object. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @return the parameter value (full precision); if the value is SQL NULL, the result is null * @exception SQLException if a database-access error occurs. */ public final BigDecimal getBigDecimal(int parameterIndex) throws SQLException { checkStatus(); try { DataValueDescriptor dvd = getParms().getParameterForGet(parameterIndex - 1); if (wasNull = dvd.isNull()) return null; return org.apache.derby.iapi.types.SQLDecimal.getBigDecimal(dvd); } catch (StandardException e) { throw EmbedResultSet.noStateChangeException(e); } }
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; // Don't fetch the getParms into a local varibale // at this point because it is possible that the activation // associated with this callable statement may have become // stale. If the current activation is invalid, a new activation // will be created for it in executeStatement call below. // We should be using the ParameterValueSet associated with // the activation associated to the CallableStatement after // the executeStatement below. That ParameterValueSet is the // 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; } }