/** * Returns <code>this</code> if this class implements the interface * * @param interfaces a Class defining an interface * @return an object that implements the interface * @throws java.sql.SQLExption if no object if found that implements the interface */ public final <T> T unwrap(java.lang.Class<T> interfaces) throws SQLException { try { if (getRealConnection().isClosed()) throw Util.noCurrentConnection(); // Derby does not implement non-standard methods on // JDBC objects try { return interfaces.cast(this); } catch (ClassCastException cce) { throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP, interfaces); } } catch (SQLException sqle) { notifyException(sqle); throw sqle; } }
/** * Returns false unless <code>interfaces</code> is implemented * * @param interfaces a Class defining an interface. * @return true if this implements the interface or directly or indirectly wraps an object that * does. * @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper * for an object with the given interface. */ public final boolean isWrapperFor(Class<?> interfaces) throws SQLException { try { if (getRealConnection().isClosed()) throw Util.noCurrentConnection(); return interfaces.isInstance(this); } catch (SQLException sqle) { notifyException(sqle); throw sqle; } }