From dev-return-192550-archive-asf-public=cust-asf.ponee.io@tomcat.apache.org Thu Aug 9 21:12:08 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 132B5180676 for ; Thu, 9 Aug 2018 21:12:05 +0200 (CEST) Received: (qmail 93604 invoked by uid 500); 9 Aug 2018 19:12:04 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 93337 invoked by uid 99); 9 Aug 2018 19:12:04 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2018 19:12:04 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 360B33A012C for ; Thu, 9 Aug 2018 19:12:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1837759 [2/6] - in /tomcat/tc8.5.x/trunk: ./ java/org/apache/tomcat/dbcp/dbcp2/ java/org/apache/tomcat/dbcp/dbcp2/cpdsadapter/ java/org/apache/tomcat/dbcp/dbcp2/datasources/ webapps/docs/ Date: Thu, 09 Aug 2018 19:12:02 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20180809191203.360B33A012C@svn01-us-west.apache.org> Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingCallableStatement.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingCallableStatement.java?rev=1837759&r1=1837758&r2=1837759&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingCallableStatement.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingCallableStatement.java Thu Aug 9 19:12:01 2018 @@ -55,51 +55,55 @@ public class DelegatingCallableStatement * Creates a wrapper for the Statement which traces this Statement to the Connection which created it and the code * which created it. * - * @param c + * @param connection * the {@link DelegatingConnection} that created this statement - * @param s + * @param statement * the {@link CallableStatement} to delegate all calls to */ - public DelegatingCallableStatement(final DelegatingConnection c, final CallableStatement s) { - super(c, s); + public DelegatingCallableStatement(final DelegatingConnection connection, final CallableStatement statement) { + super(connection, statement); } @Override - public void registerOutParameter(final int parameterIndex, final int sqlType) throws SQLException { + public Array getArray(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(parameterIndex, sqlType); + return getDelegateCallableStatement().getArray(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void registerOutParameter(final int parameterIndex, final int sqlType, final int scale) throws SQLException { + public Array getArray(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(parameterIndex, sqlType, scale); + return getDelegateCallableStatement().getArray(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public boolean wasNull() throws SQLException { + public BigDecimal getBigDecimal(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().wasNull(); + return getDelegateCallableStatement().getBigDecimal(parameterIndex); } catch (final SQLException e) { handleException(e); - return false; + return null; } } + /** @deprecated Use {@link #getBigDecimal(int)} or {@link #getBigDecimal(String)} */ @Override - public String getString(final int parameterIndex) throws SQLException { + @Deprecated + public BigDecimal getBigDecimal(final int parameterIndex, final int scale) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getString(parameterIndex); + return getDelegateCallableStatement().getBigDecimal(parameterIndex, scale); } catch (final SQLException e) { handleException(e); return null; @@ -107,65 +111,65 @@ public class DelegatingCallableStatement } @Override - public boolean getBoolean(final int parameterIndex) throws SQLException { + public BigDecimal getBigDecimal(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBoolean(parameterIndex); + return getDelegateCallableStatement().getBigDecimal(parameterName); } catch (final SQLException e) { handleException(e); - return false; + return null; } } @Override - public byte getByte(final int parameterIndex) throws SQLException { + public Blob getBlob(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getByte(parameterIndex); + return getDelegateCallableStatement().getBlob(parameterIndex); } catch (final SQLException e) { handleException(e); - return 0; + return null; } } @Override - public short getShort(final int parameterIndex) throws SQLException { + public Blob getBlob(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getShort(parameterIndex); + return getDelegateCallableStatement().getBlob(parameterName); } catch (final SQLException e) { handleException(e); - return 0; + return null; } } @Override - public int getInt(final int parameterIndex) throws SQLException { + public boolean getBoolean(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getInt(parameterIndex); + return getDelegateCallableStatement().getBoolean(parameterIndex); } catch (final SQLException e) { handleException(e); - return 0; + return false; } } @Override - public long getLong(final int parameterIndex) throws SQLException { + public boolean getBoolean(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getLong(parameterIndex); + return getDelegateCallableStatement().getBoolean(parameterName); } catch (final SQLException e) { handleException(e); - return 0; + return false; } } @Override - public float getFloat(final int parameterIndex) throws SQLException { + public byte getByte(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getFloat(parameterIndex); + return getDelegateCallableStatement().getByte(parameterIndex); } catch (final SQLException e) { handleException(e); return 0; @@ -173,23 +177,21 @@ public class DelegatingCallableStatement } @Override - public double getDouble(final int parameterIndex) throws SQLException { + public byte getByte(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getDouble(parameterIndex); + return getDelegateCallableStatement().getByte(parameterName); } catch (final SQLException e) { handleException(e); return 0; } } - /** @deprecated Use {@link #getBigDecimal(int)} or {@link #getBigDecimal(String)} */ @Override - @Deprecated - public BigDecimal getBigDecimal(final int parameterIndex, final int scale) throws SQLException { + public byte[] getBytes(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBigDecimal(parameterIndex, scale); + return getDelegateCallableStatement().getBytes(parameterIndex); } catch (final SQLException e) { handleException(e); return null; @@ -197,10 +199,10 @@ public class DelegatingCallableStatement } @Override - public byte[] getBytes(final int parameterIndex) throws SQLException { + public byte[] getBytes(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBytes(parameterIndex); + return getDelegateCallableStatement().getBytes(parameterName); } catch (final SQLException e) { handleException(e); return null; @@ -208,10 +210,10 @@ public class DelegatingCallableStatement } @Override - public Date getDate(final int parameterIndex) throws SQLException { + public Reader getCharacterStream(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getDate(parameterIndex); + return getDelegateCallableStatement().getCharacterStream(parameterIndex); } catch (final SQLException e) { handleException(e); return null; @@ -219,10 +221,10 @@ public class DelegatingCallableStatement } @Override - public Time getTime(final int parameterIndex) throws SQLException { + public Reader getCharacterStream(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTime(parameterIndex); + return getDelegateCallableStatement().getCharacterStream(parameterName); } catch (final SQLException e) { handleException(e); return null; @@ -230,10 +232,10 @@ public class DelegatingCallableStatement } @Override - public Timestamp getTimestamp(final int parameterIndex) throws SQLException { + public Clob getClob(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTimestamp(parameterIndex); + return getDelegateCallableStatement().getClob(parameterIndex); } catch (final SQLException e) { handleException(e); return null; @@ -241,10 +243,10 @@ public class DelegatingCallableStatement } @Override - public Object getObject(final int parameterIndex) throws SQLException { + public Clob getClob(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getObject(parameterIndex); + return getDelegateCallableStatement().getClob(parameterName); } catch (final SQLException e) { handleException(e); return null; @@ -252,10 +254,10 @@ public class DelegatingCallableStatement } @Override - public BigDecimal getBigDecimal(final int parameterIndex) throws SQLException { + public Date getDate(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBigDecimal(parameterIndex); + return getDelegateCallableStatement().getDate(parameterIndex); } catch (final SQLException e) { handleException(e); return null; @@ -263,10 +265,10 @@ public class DelegatingCallableStatement } @Override - public Object getObject(final int i, final Map> map) throws SQLException { + public Date getDate(final int parameterIndex, final Calendar cal) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getObject(i, map); + return getDelegateCallableStatement().getDate(parameterIndex, cal); } catch (final SQLException e) { handleException(e); return null; @@ -274,10 +276,10 @@ public class DelegatingCallableStatement } @Override - public Ref getRef(final int i) throws SQLException { + public Date getDate(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getRef(i); + return getDelegateCallableStatement().getDate(parameterName); } catch (final SQLException e) { handleException(e); return null; @@ -285,119 +287,124 @@ public class DelegatingCallableStatement } @Override - public Blob getBlob(final int i) throws SQLException { + public Date getDate(final String parameterName, final Calendar cal) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBlob(i); + return getDelegateCallableStatement().getDate(parameterName, cal); } catch (final SQLException e) { handleException(e); return null; } } + private CallableStatement getDelegateCallableStatement() { + return (CallableStatement) getDelegate(); + } + @Override - public Clob getClob(final int i) throws SQLException { + public double getDouble(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getClob(i); + return getDelegateCallableStatement().getDouble(parameterIndex); } catch (final SQLException e) { handleException(e); - return null; + return 0; } } @Override - public Array getArray(final int i) throws SQLException { + public double getDouble(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getArray(i); + return getDelegateCallableStatement().getDouble(parameterName); } catch (final SQLException e) { handleException(e); - return null; + return 0; } } @Override - public Date getDate(final int parameterIndex, final Calendar cal) throws SQLException { + public float getFloat(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getDate(parameterIndex, cal); + return getDelegateCallableStatement().getFloat(parameterIndex); } catch (final SQLException e) { handleException(e); - return null; + return 0; } } @Override - public Time getTime(final int parameterIndex, final Calendar cal) throws SQLException { + public float getFloat(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTime(parameterIndex, cal); + return getDelegateCallableStatement().getFloat(parameterName); } catch (final SQLException e) { handleException(e); - return null; + return 0; } } @Override - public Timestamp getTimestamp(final int parameterIndex, final Calendar cal) throws SQLException { + public int getInt(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTimestamp(parameterIndex, cal); + return getDelegateCallableStatement().getInt(parameterIndex); } catch (final SQLException e) { handleException(e); - return null; + return 0; } } @Override - public void registerOutParameter(final int paramIndex, final int sqlType, final String typeName) - throws SQLException { + public int getInt(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(paramIndex, sqlType, typeName); + return getDelegateCallableStatement().getInt(parameterName); } catch (final SQLException e) { handleException(e); + return 0; } } @Override - public void registerOutParameter(final String parameterName, final int sqlType) throws SQLException { + public long getLong(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(parameterName, sqlType); + return getDelegateCallableStatement().getLong(parameterIndex); } catch (final SQLException e) { handleException(e); + return 0; } } @Override - public void registerOutParameter(final String parameterName, final int sqlType, final int scale) - throws SQLException { + public long getLong(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(parameterName, sqlType, scale); + return getDelegateCallableStatement().getLong(parameterName); } catch (final SQLException e) { handleException(e); + return 0; } } @Override - public void registerOutParameter(final String parameterName, final int sqlType, final String typeName) - throws SQLException { + public Reader getNCharacterStream(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().registerOutParameter(parameterName, sqlType, typeName); + return getDelegateCallableStatement().getNCharacterStream(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public URL getURL(final int parameterIndex) throws SQLException { + public Reader getNCharacterStream(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getURL(parameterIndex); + return getDelegateCallableStatement().getNCharacterStream(parameterName); } catch (final SQLException e) { handleException(e); return null; @@ -405,258 +412,274 @@ public class DelegatingCallableStatement } @Override - public void setURL(final String parameterName, final URL val) throws SQLException { + public NClob getNClob(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setURL(parameterName, val); + return getDelegateCallableStatement().getNClob(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setNull(final String parameterName, final int sqlType) throws SQLException { + public NClob getNClob(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNull(parameterName, sqlType); + return getDelegateCallableStatement().getNClob(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setBoolean(final String parameterName, final boolean x) throws SQLException { + public String getNString(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBoolean(parameterName, x); + return getDelegateCallableStatement().getNString(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setByte(final String parameterName, final byte x) throws SQLException { + public String getNString(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setByte(parameterName, x); + return getDelegateCallableStatement().getNString(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setShort(final String parameterName, final short x) throws SQLException { + public Object getObject(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setShort(parameterName, x); + return getDelegateCallableStatement().getObject(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setInt(final String parameterName, final int x) throws SQLException { + public T getObject(final int parameterIndex, final Class type) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setInt(parameterName, x); + return getDelegateCallableStatement().getObject(parameterIndex, type); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setLong(final String parameterName, final long x) throws SQLException { + public Object getObject(final int i, final Map> map) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setLong(parameterName, x); + return getDelegateCallableStatement().getObject(i, map); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setFloat(final String parameterName, final float x) throws SQLException { + public Object getObject(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setFloat(parameterName, x); + return getDelegateCallableStatement().getObject(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setDouble(final String parameterName, final double x) throws SQLException { + public T getObject(final String parameterName, final Class type) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setDouble(parameterName, x); + return getDelegateCallableStatement().getObject(parameterName, type); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setBigDecimal(final String parameterName, final BigDecimal x) throws SQLException { + public Object getObject(final String parameterName, final Map> map) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBigDecimal(parameterName, x); + return getDelegateCallableStatement().getObject(parameterName, map); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setString(final String parameterName, final String x) throws SQLException { + public Ref getRef(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setString(parameterName, x); + return getDelegateCallableStatement().getRef(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setBytes(final String parameterName, final byte[] x) throws SQLException { + public Ref getRef(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBytes(parameterName, x); + return getDelegateCallableStatement().getRef(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setDate(final String parameterName, final Date x) throws SQLException { + public RowId getRowId(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setDate(parameterName, x); + return getDelegateCallableStatement().getRowId(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setTime(final String parameterName, final Time x) throws SQLException { + public RowId getRowId(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setTime(parameterName, x); + return getDelegateCallableStatement().getRowId(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setTimestamp(final String parameterName, final Timestamp x) throws SQLException { + public short getShort(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setTimestamp(parameterName, x); + return getDelegateCallableStatement().getShort(parameterIndex); } catch (final SQLException e) { handleException(e); + return 0; } } @Override - public void setAsciiStream(final String parameterName, final InputStream x, final int length) throws SQLException { + public short getShort(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setAsciiStream(parameterName, x, length); + return getDelegateCallableStatement().getShort(parameterName); } catch (final SQLException e) { handleException(e); + return 0; } } @Override - public void setBinaryStream(final String parameterName, final InputStream x, final int length) throws SQLException { + public SQLXML getSQLXML(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBinaryStream(parameterName, x, length); + return getDelegateCallableStatement().getSQLXML(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setObject(final String parameterName, final Object x, final int targetSqlType, final int scale) - throws SQLException { + public SQLXML getSQLXML(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setObject(parameterName, x, targetSqlType, scale); + return getDelegateCallableStatement().getSQLXML(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setObject(final String parameterName, final Object x, final int targetSqlType) throws SQLException { + public String getString(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setObject(parameterName, x, targetSqlType); + return getDelegateCallableStatement().getString(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setObject(final String parameterName, final Object x) throws SQLException { + public String getString(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setObject(parameterName, x); + return getDelegateCallableStatement().getString(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setCharacterStream(final String parameterName, final Reader reader, final int length) - throws SQLException { - checkOpen(); - getDelegateCallableStatement().setCharacterStream(parameterName, reader, length); - } - - @Override - public void setDate(final String parameterName, final Date x, final Calendar cal) throws SQLException { + public Time getTime(final int parameterIndex) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setDate(parameterName, x, cal); + return getDelegateCallableStatement().getTime(parameterIndex); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setTime(final String parameterName, final Time x, final Calendar cal) throws SQLException { + public Time getTime(final int parameterIndex, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setTime(parameterName, x, cal); + return getDelegateCallableStatement().getTime(parameterIndex, cal); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setTimestamp(final String parameterName, final Timestamp x, final Calendar cal) throws SQLException { + public Time getTime(final String parameterName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setTimestamp(parameterName, x, cal); + return getDelegateCallableStatement().getTime(parameterName); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public void setNull(final String parameterName, final int sqlType, final String typeName) throws SQLException { + public Time getTime(final String parameterName, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNull(parameterName, sqlType, typeName); + return getDelegateCallableStatement().getTime(parameterName, cal); } catch (final SQLException e) { handleException(e); + return null; } } @Override - public String getString(final String parameterName) throws SQLException { + public Timestamp getTimestamp(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getString(parameterName); + return getDelegateCallableStatement().getTimestamp(parameterIndex); } catch (final SQLException e) { handleException(e); return null; @@ -664,309 +687,299 @@ public class DelegatingCallableStatement } @Override - public boolean getBoolean(final String parameterName) throws SQLException { + public Timestamp getTimestamp(final int parameterIndex, final Calendar cal) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBoolean(parameterName); + return getDelegateCallableStatement().getTimestamp(parameterIndex, cal); } catch (final SQLException e) { handleException(e); - return false; + return null; } } @Override - public byte getByte(final String parameterName) throws SQLException { + public Timestamp getTimestamp(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getByte(parameterName); + return getDelegateCallableStatement().getTimestamp(parameterName); } catch (final SQLException e) { handleException(e); - return 0; + return null; } } @Override - public short getShort(final String parameterName) throws SQLException { + public Timestamp getTimestamp(final String parameterName, final Calendar cal) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getShort(parameterName); + return getDelegateCallableStatement().getTimestamp(parameterName, cal); } catch (final SQLException e) { handleException(e); - return 0; + return null; } } @Override - public int getInt(final String parameterName) throws SQLException { + public URL getURL(final int parameterIndex) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getInt(parameterName); + return getDelegateCallableStatement().getURL(parameterIndex); } catch (final SQLException e) { handleException(e); - return 0; + return null; } } @Override - public long getLong(final String parameterName) throws SQLException { + public URL getURL(final String parameterName) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getLong(parameterName); + return getDelegateCallableStatement().getURL(parameterName); } catch (final SQLException e) { handleException(e); - return 0; + return null; } } @Override - public float getFloat(final String parameterName) throws SQLException { + public void registerOutParameter(final int parameterIndex, final int sqlType) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getFloat(parameterName); + getDelegateCallableStatement().registerOutParameter(parameterIndex, sqlType); } catch (final SQLException e) { handleException(e); - return 0; } } @Override - public double getDouble(final String parameterName) throws SQLException { + public void registerOutParameter(final int parameterIndex, final int sqlType, final int scale) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getDouble(parameterName); + getDelegateCallableStatement().registerOutParameter(parameterIndex, sqlType, scale); } catch (final SQLException e) { handleException(e); - return 0; } } @Override - public byte[] getBytes(final String parameterName) throws SQLException { + public void registerOutParameter(final int paramIndex, final int sqlType, final String typeName) + throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBytes(parameterName); + getDelegateCallableStatement().registerOutParameter(paramIndex, sqlType, typeName); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Date getDate(final String parameterName) throws SQLException { + public void registerOutParameter(final String parameterName, final int sqlType) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getDate(parameterName); + getDelegateCallableStatement().registerOutParameter(parameterName, sqlType); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Time getTime(final String parameterName) throws SQLException { + public void registerOutParameter(final String parameterName, final int sqlType, final int scale) + throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTime(parameterName); + getDelegateCallableStatement().registerOutParameter(parameterName, sqlType, scale); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Timestamp getTimestamp(final String parameterName) throws SQLException { + public void registerOutParameter(final String parameterName, final int sqlType, final String typeName) + throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTimestamp(parameterName); + getDelegateCallableStatement().registerOutParameter(parameterName, sqlType, typeName); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Object getObject(final String parameterName) throws SQLException { + public void setAsciiStream(final String parameterName, final InputStream inputStream) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getObject(parameterName); + getDelegateCallableStatement().setAsciiStream(parameterName, inputStream); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public BigDecimal getBigDecimal(final String parameterName) throws SQLException { + public void setAsciiStream(final String parameterName, final InputStream x, final int length) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBigDecimal(parameterName); + getDelegateCallableStatement().setAsciiStream(parameterName, x, length); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Object getObject(final String parameterName, final Map> map) throws SQLException { + public void setAsciiStream(final String parameterName, final InputStream inputStream, final long length) + throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getObject(parameterName, map); + getDelegateCallableStatement().setAsciiStream(parameterName, inputStream, length); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Ref getRef(final String parameterName) throws SQLException { + public void setBigDecimal(final String parameterName, final BigDecimal x) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getRef(parameterName); + getDelegateCallableStatement().setBigDecimal(parameterName, x); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Blob getBlob(final String parameterName) throws SQLException { + public void setBinaryStream(final String parameterName, final InputStream inputStream) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getBlob(parameterName); + getDelegateCallableStatement().setBinaryStream(parameterName, inputStream); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Clob getClob(final String parameterName) throws SQLException { + public void setBinaryStream(final String parameterName, final InputStream x, final int length) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getClob(parameterName); + getDelegateCallableStatement().setBinaryStream(parameterName, x, length); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Array getArray(final String parameterName) throws SQLException { + public void setBinaryStream(final String parameterName, final InputStream inputStream, final long length) + throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getArray(parameterName); + getDelegateCallableStatement().setBinaryStream(parameterName, inputStream, length); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Date getDate(final String parameterName, final Calendar cal) throws SQLException { + public void setBlob(final String parameterName, final Blob blob) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getDate(parameterName, cal); + getDelegateCallableStatement().setBlob(parameterName, blob); } catch (final SQLException e) { handleException(e); - return null; } } - private CallableStatement getDelegateCallableStatement() { - return (CallableStatement) getDelegate(); - } - @Override - public Time getTime(final String parameterName, final Calendar cal) throws SQLException { + public void setBlob(final String parameterName, final InputStream inputStream) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTime(parameterName, cal); + getDelegateCallableStatement().setBlob(parameterName, inputStream); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Timestamp getTimestamp(final String parameterName, final Calendar cal) throws SQLException { + public void setBlob(final String parameterName, final InputStream inputStream, final long length) + throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getTimestamp(parameterName, cal); + getDelegateCallableStatement().setBlob(parameterName, inputStream, length); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public URL getURL(final String parameterName) throws SQLException { + public void setBoolean(final String parameterName, final boolean x) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getURL(parameterName); + getDelegateCallableStatement().setBoolean(parameterName, x); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public RowId getRowId(final int parameterIndex) throws SQLException { + public void setByte(final String parameterName, final byte x) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getRowId(parameterIndex); + getDelegateCallableStatement().setByte(parameterName, x); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public RowId getRowId(final String parameterName) throws SQLException { + public void setBytes(final String parameterName, final byte[] x) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getRowId(parameterName); + getDelegateCallableStatement().setBytes(parameterName, x); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public void setRowId(final String parameterName, final RowId value) throws SQLException { + public void setCharacterStream(final String parameterName, final Reader reader) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setRowId(parameterName, value); + getDelegateCallableStatement().setCharacterStream(parameterName, reader); } catch (final SQLException e) { handleException(e); } } @Override - public void setNString(final String parameterName, final String value) throws SQLException { + public void setCharacterStream(final String parameterName, final Reader reader, final int length) + throws SQLException { + checkOpen(); + getDelegateCallableStatement().setCharacterStream(parameterName, reader, length); + } + + @Override + public void setCharacterStream(final String parameterName, final Reader reader, final long length) + throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNString(parameterName, value); + getDelegateCallableStatement().setCharacterStream(parameterName, reader, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setNCharacterStream(final String parameterName, final Reader reader, final long length) - throws SQLException { + public void setClob(final String parameterName, final Clob clob) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNCharacterStream(parameterName, reader, length); + getDelegateCallableStatement().setClob(parameterName, clob); } catch (final SQLException e) { handleException(e); } } @Override - public void setNClob(final String parameterName, final NClob value) throws SQLException { + public void setClob(final String parameterName, final Reader reader) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNClob(parameterName, value); + getDelegateCallableStatement().setClob(parameterName, reader); } catch (final SQLException e) { handleException(e); } @@ -983,288 +996,275 @@ public class DelegatingCallableStatement } @Override - public void setBlob(final String parameterName, final InputStream inputStream, final long length) - throws SQLException { + public void setDate(final String parameterName, final Date x) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBlob(parameterName, inputStream, length); + getDelegateCallableStatement().setDate(parameterName, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setNClob(final String parameterName, final Reader reader, final long length) throws SQLException { + public void setDate(final String parameterName, final Date x, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNClob(parameterName, reader, length); + getDelegateCallableStatement().setDate(parameterName, x, cal); } catch (final SQLException e) { handleException(e); } } @Override - public NClob getNClob(final int parameterIndex) throws SQLException { + public void setDouble(final String parameterName, final double x) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getNClob(parameterIndex); + getDelegateCallableStatement().setDouble(parameterName, x); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public NClob getNClob(final String parameterName) throws SQLException { + public void setFloat(final String parameterName, final float x) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getNClob(parameterName); + getDelegateCallableStatement().setFloat(parameterName, x); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public void setSQLXML(final String parameterName, final SQLXML value) throws SQLException { + public void setInt(final String parameterName, final int x) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setSQLXML(parameterName, value); + getDelegateCallableStatement().setInt(parameterName, x); } catch (final SQLException e) { handleException(e); } } @Override - public SQLXML getSQLXML(final int parameterIndex) throws SQLException { + public void setLong(final String parameterName, final long x) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getSQLXML(parameterIndex); + getDelegateCallableStatement().setLong(parameterName, x); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public SQLXML getSQLXML(final String parameterName) throws SQLException { + public void setNCharacterStream(final String parameterName, final Reader reader) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getSQLXML(parameterName); + getDelegateCallableStatement().setNCharacterStream(parameterName, reader); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public String getNString(final int parameterIndex) throws SQLException { + public void setNCharacterStream(final String parameterName, final Reader reader, final long length) + throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getNString(parameterIndex); + getDelegateCallableStatement().setNCharacterStream(parameterName, reader, length); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public String getNString(final String parameterName) throws SQLException { + public void setNClob(final String parameterName, final NClob value) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getNString(parameterName); + getDelegateCallableStatement().setNClob(parameterName, value); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Reader getNCharacterStream(final int parameterIndex) throws SQLException { + public void setNClob(final String parameterName, final Reader reader) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getNCharacterStream(parameterIndex); + getDelegateCallableStatement().setNClob(parameterName, reader); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Reader getNCharacterStream(final String parameterName) throws SQLException { + public void setNClob(final String parameterName, final Reader reader, final long length) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getNCharacterStream(parameterName); + getDelegateCallableStatement().setNClob(parameterName, reader, length); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Reader getCharacterStream(final int parameterIndex) throws SQLException { + public void setNString(final String parameterName, final String value) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getCharacterStream(parameterIndex); + getDelegateCallableStatement().setNString(parameterName, value); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public Reader getCharacterStream(final String parameterName) throws SQLException { + public void setNull(final String parameterName, final int sqlType) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getCharacterStream(parameterName); + getDelegateCallableStatement().setNull(parameterName, sqlType); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public void setBlob(final String parameterName, final Blob blob) throws SQLException { + public void setNull(final String parameterName, final int sqlType, final String typeName) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBlob(parameterName, blob); + getDelegateCallableStatement().setNull(parameterName, sqlType, typeName); } catch (final SQLException e) { handleException(e); } } @Override - public void setClob(final String parameterName, final Clob clob) throws SQLException { + public void setObject(final String parameterName, final Object x) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setClob(parameterName, clob); + getDelegateCallableStatement().setObject(parameterName, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setAsciiStream(final String parameterName, final InputStream inputStream, final long length) - throws SQLException { + public void setObject(final String parameterName, final Object x, final int targetSqlType) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setAsciiStream(parameterName, inputStream, length); + getDelegateCallableStatement().setObject(parameterName, x, targetSqlType); } catch (final SQLException e) { handleException(e); } } @Override - public void setBinaryStream(final String parameterName, final InputStream inputStream, final long length) + public void setObject(final String parameterName, final Object x, final int targetSqlType, final int scale) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBinaryStream(parameterName, inputStream, length); + getDelegateCallableStatement().setObject(parameterName, x, targetSqlType, scale); } catch (final SQLException e) { handleException(e); } } @Override - public void setCharacterStream(final String parameterName, final Reader reader, final long length) - throws SQLException { + public void setRowId(final String parameterName, final RowId value) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setCharacterStream(parameterName, reader, length); + getDelegateCallableStatement().setRowId(parameterName, value); } catch (final SQLException e) { handleException(e); } } @Override - public void setAsciiStream(final String parameterName, final InputStream inputStream) throws SQLException { + public void setShort(final String parameterName, final short x) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setAsciiStream(parameterName, inputStream); + getDelegateCallableStatement().setShort(parameterName, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setBinaryStream(final String parameterName, final InputStream inputStream) throws SQLException { + public void setSQLXML(final String parameterName, final SQLXML value) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBinaryStream(parameterName, inputStream); + getDelegateCallableStatement().setSQLXML(parameterName, value); } catch (final SQLException e) { handleException(e); } } @Override - public void setCharacterStream(final String parameterName, final Reader reader) throws SQLException { + public void setString(final String parameterName, final String x) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setCharacterStream(parameterName, reader); + getDelegateCallableStatement().setString(parameterName, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setNCharacterStream(final String parameterName, final Reader reader) throws SQLException { + public void setTime(final String parameterName, final Time x) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNCharacterStream(parameterName, reader); + getDelegateCallableStatement().setTime(parameterName, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setClob(final String parameterName, final Reader reader) throws SQLException { + public void setTime(final String parameterName, final Time x, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setClob(parameterName, reader); + getDelegateCallableStatement().setTime(parameterName, x, cal); } catch (final SQLException e) { handleException(e); } } @Override - public void setBlob(final String parameterName, final InputStream inputStream) throws SQLException { + public void setTimestamp(final String parameterName, final Timestamp x) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setBlob(parameterName, inputStream); + getDelegateCallableStatement().setTimestamp(parameterName, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setNClob(final String parameterName, final Reader reader) throws SQLException { + public void setTimestamp(final String parameterName, final Timestamp x, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegateCallableStatement().setNClob(parameterName, reader); + getDelegateCallableStatement().setTimestamp(parameterName, x, cal); } catch (final SQLException e) { handleException(e); } } @Override - public T getObject(final int parameterIndex, final Class type) throws SQLException { + public void setURL(final String parameterName, final URL val) throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getObject(parameterIndex, type); + getDelegateCallableStatement().setURL(parameterName, val); } catch (final SQLException e) { handleException(e); - return null; } } @Override - public T getObject(final String parameterName, final Class type) throws SQLException { + public boolean wasNull() throws SQLException { checkOpen(); try { - return getDelegateCallableStatement().getObject(parameterName, type); + return getDelegateCallableStatement().wasNull(); } catch (final SQLException e) { handleException(e); - return null; + return false; } } Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingConnection.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingConnection.java?rev=1837759&r1=1837758&r2=1837759&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingConnection.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingConnection.java Thu Aug 9 19:12:01 2018 @@ -224,8 +224,20 @@ public class DelegatingConnection - * Hence this method will return the first delegate that is not a {@code DelegatingResultSet}, or {@code null} when - * no non-{@code DelegatingResultSet} delegate can be found by traversing this chain. - *

- *

- * This method is useful when you may have nested {@code DelegatingResultSet}s, and you want to make sure to obtain - * a "genuine" {@link ResultSet}. - *

- * - * @return the innermost database meta data. - */ - public DatabaseMetaData getInnermostDelegate() { - DatabaseMetaData m = databaseMetaData; - while (m != null && m instanceof DelegatingDatabaseMetaData) { - m = ((DelegatingDatabaseMetaData) m).getDelegate(); - if (this == m) { - return null; - } - } - return m; - } - - protected void handleException(final SQLException e) throws SQLException { - if (connection != null) { - connection.handleException(e); - } else { - throw e; - } - } - @Override public boolean allProceduresAreCallable() throws SQLException { try { @@ -119,6 +77,16 @@ public class DelegatingDatabaseMetaData } @Override + public boolean autoCommitFailureClosesAllResultSets() throws SQLException { + try { + return databaseMetaData.autoCommitFailureClosesAllResultSets(); + } catch (final SQLException e) { + handleException(e); + return false; + } + } + + @Override public boolean dataDefinitionCausesTransactionCommit() throws SQLException { try { return databaseMetaData.dataDefinitionCausesTransactionCommit(); @@ -159,6 +127,17 @@ public class DelegatingDatabaseMetaData } @Override + public boolean generatedKeyAlwaysReturned() throws SQLException { + connection.checkOpen(); + try { + return databaseMetaData.generatedKeyAlwaysReturned(); + } catch (final SQLException e) { + handleException(e); + return false; + } + } + + @Override public ResultSet getAttributes(final String catalog, final String schemaPattern, final String typeNamePattern, final String attributeNamePattern) throws SQLException { connection.checkOpen(); @@ -185,6 +164,17 @@ public class DelegatingDatabaseMetaData } @Override + public ResultSet getCatalogs() throws SQLException { + connection.checkOpen(); + try { + return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getCatalogs()); + } catch (final SQLException e) { + handleException(e); + throw new AssertionError(); + } + } + + @Override public String getCatalogSeparator() throws SQLException { try { return databaseMetaData.getCatalogSeparator(); @@ -205,10 +195,10 @@ public class DelegatingDatabaseMetaData } @Override - public ResultSet getCatalogs() throws SQLException { + public ResultSet getClientInfoProperties() throws SQLException { connection.checkOpen(); try { - return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getCatalogs()); + return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getClientInfoProperties()); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -309,6 +299,15 @@ public class DelegatingDatabaseMetaData } } + /** + * Gets the underlying database meta data. + * + * @return The underlying database meta data. + */ + public DatabaseMetaData getDelegate() { + return databaseMetaData; + } + @Override public int getDriverMajorVersion() { return databaseMetaData.getDriverMajorVersion(); @@ -363,6 +362,32 @@ public class DelegatingDatabaseMetaData } @Override + public ResultSet getFunctionColumns(final String catalog, final String schemaPattern, + final String functionNamePattern, final String columnNamePattern) throws SQLException { + connection.checkOpen(); + try { + return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getFunctionColumns(catalog, + schemaPattern, functionNamePattern, columnNamePattern)); + } catch (final SQLException e) { + handleException(e); + throw new AssertionError(); + } + } + + @Override + public ResultSet getFunctions(final String catalog, final String schemaPattern, final String functionNamePattern) + throws SQLException { + connection.checkOpen(); + try { + return DelegatingResultSet.wrapResultSet(connection, + databaseMetaData.getFunctions(catalog, schemaPattern, functionNamePattern)); + } catch (final SQLException e) { + handleException(e); + throw new AssertionError(); + } + } + + @Override public String getIdentifierQuoteString() throws SQLException { try { return databaseMetaData.getIdentifierQuoteString(); @@ -398,6 +423,31 @@ public class DelegatingDatabaseMetaData } } + /** + * If my underlying {@link ResultSet} is not a {@code DelegatingResultSet}, returns it, otherwise recursively + * invokes this method on my delegate. + *

+ * Hence this method will return the first delegate that is not a {@code DelegatingResultSet}, or {@code null} when + * no non-{@code DelegatingResultSet} delegate can be found by traversing this chain. + *

+ *

+ * This method is useful when you may have nested {@code DelegatingResultSet}s, and you want to make sure to obtain + * a "genuine" {@link ResultSet}. + *

+ * + * @return the innermost database meta data. + */ + public DatabaseMetaData getInnermostDelegate() { + DatabaseMetaData m = databaseMetaData; + while (m != null && m instanceof DelegatingDatabaseMetaData) { + m = ((DelegatingDatabaseMetaData) m).getDelegate(); + if (this == m) { + return null; + } + } + return m; + } + @Override public int getJDBCMajorVersion() throws SQLException { try { @@ -654,6 +704,19 @@ public class DelegatingDatabaseMetaData } @Override + public ResultSet getProcedures(final String catalog, final String schemaPattern, final String procedureNamePattern) + throws SQLException { + connection.checkOpen(); + try { + return DelegatingResultSet.wrapResultSet(connection, + databaseMetaData.getProcedures(catalog, schemaPattern, procedureNamePattern)); + } catch (final SQLException e) { + handleException(e); + throw new AssertionError(); + } + } + + @Override public String getProcedureTerm() throws SQLException { try { return databaseMetaData.getProcedureTerm(); @@ -664,12 +727,12 @@ public class DelegatingDatabaseMetaData } @Override - public ResultSet getProcedures(final String catalog, final String schemaPattern, final String procedureNamePattern) - throws SQLException { + public ResultSet getPseudoColumns(final String catalog, final String schemaPattern, final String tableNamePattern, + final String columnNamePattern) throws SQLException { connection.checkOpen(); try { return DelegatingResultSet.wrapResultSet(connection, - databaseMetaData.getProcedures(catalog, schemaPattern, procedureNamePattern)); + databaseMetaData.getPseudoColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern)); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -687,9 +750,9 @@ public class DelegatingDatabaseMetaData } @Override - public String getSQLKeywords() throws SQLException { + public RowIdLifetime getRowIdLifetime() throws SQLException { try { - return databaseMetaData.getSQLKeywords(); + return databaseMetaData.getRowIdLifetime(); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -697,19 +760,21 @@ public class DelegatingDatabaseMetaData } @Override - public int getSQLStateType() throws SQLException { + public ResultSet getSchemas() throws SQLException { + connection.checkOpen(); try { - return databaseMetaData.getSQLStateType(); + return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas()); } catch (final SQLException e) { handleException(e); - return 0; + throw new AssertionError(); } } @Override - public String getSchemaTerm() throws SQLException { + public ResultSet getSchemas(final String catalog, final String schemaPattern) throws SQLException { + connection.checkOpen(); try { - return databaseMetaData.getSchemaTerm(); + return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas(catalog, schemaPattern)); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -717,10 +782,9 @@ public class DelegatingDatabaseMetaData } @Override - public ResultSet getSchemas() throws SQLException { - connection.checkOpen(); + public String getSchemaTerm() throws SQLException { try { - return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas()); + return databaseMetaData.getSchemaTerm(); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -738,6 +802,26 @@ public class DelegatingDatabaseMetaData } @Override + public String getSQLKeywords() throws SQLException { + try { + return databaseMetaData.getSQLKeywords(); + } catch (final SQLException e) { + handleException(e); + throw new AssertionError(); + } + } + + @Override + public int getSQLStateType() throws SQLException { + try { + return databaseMetaData.getSQLStateType(); + } catch (final SQLException e) { + handleException(e); + return 0; + } + } + + @Override public String getStringFunctions() throws SQLException { try { return databaseMetaData.getStringFunctions(); @@ -797,10 +881,12 @@ public class DelegatingDatabaseMetaData } @Override - public ResultSet getTableTypes() throws SQLException { + public ResultSet getTables(final String catalog, final String schemaPattern, final String tableNamePattern, + final String[] types) throws SQLException { connection.checkOpen(); try { - return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getTableTypes()); + return DelegatingResultSet.wrapResultSet(connection, + databaseMetaData.getTables(catalog, schemaPattern, tableNamePattern, types)); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -808,12 +894,10 @@ public class DelegatingDatabaseMetaData } @Override - public ResultSet getTables(final String catalog, final String schemaPattern, final String tableNamePattern, - final String[] types) throws SQLException { + public ResultSet getTableTypes() throws SQLException { connection.checkOpen(); try { - return DelegatingResultSet.wrapResultSet(connection, - databaseMetaData.getTables(catalog, schemaPattern, tableNamePattern, types)); + return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getTableTypes()); } catch (final SQLException e) { handleException(e); throw new AssertionError(); @@ -887,6 +971,14 @@ public class DelegatingDatabaseMetaData } } + protected void handleException(final SQLException e) throws SQLException { + if (connection != null) { + connection.handleException(e); + } else { + throw e; + } + } + @Override public boolean insertsAreDetected(final int type) throws SQLException { try { @@ -918,6 +1010,17 @@ public class DelegatingDatabaseMetaData } @Override + public boolean isWrapperFor(final Class iface) throws SQLException { + if (iface.isAssignableFrom(getClass())) { + return true; + } else if (iface.isAssignableFrom(databaseMetaData.getClass())) { + return true; + } else { + return databaseMetaData.isWrapperFor(iface); + } + } + + @Override public boolean locatorsUpdateCopy() throws SQLException { try { return databaseMetaData.locatorsUpdateCopy(); @@ -1098,9 +1201,9 @@ public class DelegatingDatabaseMetaData } @Override - public boolean supportsANSI92EntryLevelSQL() throws SQLException { + public boolean supportsAlterTableWithAddColumn() throws SQLException { try { - return databaseMetaData.supportsANSI92EntryLevelSQL(); + return databaseMetaData.supportsAlterTableWithAddColumn(); } catch (final SQLException e) { handleException(e); return false; @@ -1108,9 +1211,9 @@ public class DelegatingDatabaseMetaData } @Override - public boolean supportsANSI92FullSQL() throws SQLException { + public boolean supportsAlterTableWithDropColumn() throws SQLException { try { - return databaseMetaData.supportsANSI92FullSQL(); + return databaseMetaData.supportsAlterTableWithDropColumn(); } catch (final SQLException e) { handleException(e); return false; @@ -1118,9 +1221,9 @@ public class DelegatingDatabaseMetaData } @Override - public boolean supportsANSI92IntermediateSQL() throws SQLException { + public boolean supportsANSI92EntryLevelSQL() throws SQLException { try { - return databaseMetaData.supportsANSI92IntermediateSQL(); + return databaseMetaData.supportsANSI92EntryLevelSQL(); } catch (final SQLException e) { handleException(e); return false; @@ -1128,9 +1231,9 @@ public class DelegatingDatabaseMetaData } @Override - public boolean supportsAlterTableWithAddColumn() throws SQLException { + public boolean supportsANSI92FullSQL() throws SQLException { try { - return databaseMetaData.supportsAlterTableWithAddColumn(); + return databaseMetaData.supportsANSI92FullSQL(); } catch (final SQLException e) { handleException(e); return false; @@ -1138,9 +1241,9 @@ public class DelegatingDatabaseMetaData } @Override - public boolean supportsAlterTableWithDropColumn() throws SQLException { + public boolean supportsANSI92IntermediateSQL() throws SQLException { try { - return databaseMetaData.supportsAlterTableWithDropColumn(); + return databaseMetaData.supportsANSI92IntermediateSQL(); } catch (final SQLException e) { handleException(e); return false; @@ -1658,6 +1761,16 @@ public class DelegatingDatabaseMetaData } @Override + public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { + try { + return databaseMetaData.supportsStoredFunctionsUsingCallSyntax(); + } catch (final SQLException e) { + handleException(e); + return false; + } + } + + @Override public boolean supportsStoredProcedures() throws SQLException { try { return databaseMetaData.supportsStoredProcedures(); @@ -1667,6 +1780,8 @@ public class DelegatingDatabaseMetaData } } + /* JDBC_4_ANT_KEY_BEGIN */ + @Override public boolean supportsSubqueriesInComparisons() throws SQLException { try { @@ -1757,48 +1872,7 @@ public class DelegatingDatabaseMetaData } } - @Override - public boolean updatesAreDetected(final int type) throws SQLException { - try { - return databaseMetaData.updatesAreDetected(type); - } catch (final SQLException e) { - handleException(e); - return false; - } - } - - @Override - public boolean usesLocalFilePerTable() throws SQLException { - try { - return databaseMetaData.usesLocalFilePerTable(); - } catch (final SQLException e) { - handleException(e); - return false; - } - } - - @Override - public boolean usesLocalFiles() throws SQLException { - try { - return databaseMetaData.usesLocalFiles(); - } catch (final SQLException e) { - handleException(e); - return false; - } - } - - /* JDBC_4_ANT_KEY_BEGIN */ - - @Override - public boolean isWrapperFor(final Class iface) throws SQLException { - if (iface.isAssignableFrom(getClass())) { - return true; - } else if (iface.isAssignableFrom(databaseMetaData.getClass())) { - return true; - } else { - return databaseMetaData.isWrapperFor(iface); - } - } + /* JDBC_4_ANT_KEY_END */ @Override public T unwrap(final Class iface) throws SQLException { @@ -1812,30 +1886,9 @@ public class DelegatingDatabaseMetaData } @Override - public RowIdLifetime getRowIdLifetime() throws SQLException { - try { - return databaseMetaData.getRowIdLifetime(); - } catch (final SQLException e) { - handleException(e); - throw new AssertionError(); - } - } - - @Override - public ResultSet getSchemas(final String catalog, final String schemaPattern) throws SQLException { - connection.checkOpen(); - try { - return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getSchemas(catalog, schemaPattern)); - } catch (final SQLException e) { - handleException(e); - throw new AssertionError(); - } - } - - @Override - public boolean autoCommitFailureClosesAllResultSets() throws SQLException { + public boolean updatesAreDetected(final int type) throws SQLException { try { - return databaseMetaData.autoCommitFailureClosesAllResultSets(); + return databaseMetaData.updatesAreDetected(type); } catch (final SQLException e) { handleException(e); return false; @@ -1843,9 +1896,9 @@ public class DelegatingDatabaseMetaData } @Override - public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException { + public boolean usesLocalFilePerTable() throws SQLException { try { - return databaseMetaData.supportsStoredFunctionsUsingCallSyntax(); + return databaseMetaData.usesLocalFilePerTable(); } catch (final SQLException e) { handleException(e); return false; @@ -1853,62 +1906,9 @@ public class DelegatingDatabaseMetaData } @Override - public ResultSet getClientInfoProperties() throws SQLException { - connection.checkOpen(); - try { - return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getClientInfoProperties()); - } catch (final SQLException e) { - handleException(e); - throw new AssertionError(); - } - } - - @Override - public ResultSet getFunctions(final String catalog, final String schemaPattern, final String functionNamePattern) - throws SQLException { - connection.checkOpen(); - try { - return DelegatingResultSet.wrapResultSet(connection, - databaseMetaData.getFunctions(catalog, schemaPattern, functionNamePattern)); - } catch (final SQLException e) { - handleException(e); - throw new AssertionError(); - } - } - - @Override - public ResultSet getFunctionColumns(final String catalog, final String schemaPattern, - final String functionNamePattern, final String columnNamePattern) throws SQLException { - connection.checkOpen(); - try { - return DelegatingResultSet.wrapResultSet(connection, databaseMetaData.getFunctionColumns(catalog, - schemaPattern, functionNamePattern, columnNamePattern)); - } catch (final SQLException e) { - handleException(e); - throw new AssertionError(); - } - } - - /* JDBC_4_ANT_KEY_END */ - - @Override - public ResultSet getPseudoColumns(final String catalog, final String schemaPattern, final String tableNamePattern, - final String columnNamePattern) throws SQLException { - connection.checkOpen(); - try { - return DelegatingResultSet.wrapResultSet(connection, - databaseMetaData.getPseudoColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern)); - } catch (final SQLException e) { - handleException(e); - throw new AssertionError(); - } - } - - @Override - public boolean generatedKeyAlwaysReturned() throws SQLException { - connection.checkOpen(); + public boolean usesLocalFiles() throws SQLException { try { - return databaseMetaData.generatedKeyAlwaysReturned(); + return databaseMetaData.usesLocalFiles(); } catch (final SQLException e) { handleException(e); return false; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org