Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingPreparedStatement.java URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingPreparedStatement.java?rev=1837759&r1=1837758&r2=1837759&view=diff ============================================================================== --- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingPreparedStatement.java (original) +++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/dbcp/dbcp2/DelegatingPreparedStatement.java Thu Aug 9 19:12:01 2018 @@ -64,414 +64,404 @@ public class DelegatingPreparedStatement } @Override - public ResultSet executeQuery() throws SQLException { + public void addBatch() throws SQLException { checkOpen(); - if (getConnectionInternal() != null) { - getConnectionInternal().setLastUsed(); - } try { - return DelegatingResultSet.wrapResultSet(this, getDelegatePreparedStatement().executeQuery()); + getDelegatePreparedStatement().addBatch(); } catch (final SQLException e) { handleException(e); - throw new AssertionError(); } } @Override - public int executeUpdate() throws SQLException { + public void clearParameters() throws SQLException { checkOpen(); - if (getConnectionInternal() != null) { - getConnectionInternal().setLastUsed(); - } try { - return getDelegatePreparedStatement().executeUpdate(); + getDelegatePreparedStatement().clearParameters(); } catch (final SQLException e) { handleException(e); - return 0; } } - private PreparedStatement getDelegatePreparedStatement() { - return (PreparedStatement) getDelegate(); - } - @Override - public void setNull(final int parameterIndex, final int sqlType) throws SQLException { + public boolean execute() throws SQLException { checkOpen(); + if (getConnectionInternal() != null) { + getConnectionInternal().setLastUsed(); + } try { - getDelegatePreparedStatement().setNull(parameterIndex, sqlType); + return getDelegatePreparedStatement().execute(); } catch (final SQLException e) { handleException(e); + return false; } } @Override - public void setBoolean(final int parameterIndex, final boolean x) throws SQLException { + public ResultSet executeQuery() throws SQLException { checkOpen(); + if (getConnectionInternal() != null) { + getConnectionInternal().setLastUsed(); + } try { - getDelegatePreparedStatement().setBoolean(parameterIndex, x); + return DelegatingResultSet.wrapResultSet(this, getDelegatePreparedStatement().executeQuery()); } catch (final SQLException e) { handleException(e); + throw new AssertionError(); } } @Override - public void setByte(final int parameterIndex, final byte x) throws SQLException { + public int executeUpdate() throws SQLException { checkOpen(); + if (getConnectionInternal() != null) { + getConnectionInternal().setLastUsed(); + } try { - getDelegatePreparedStatement().setByte(parameterIndex, x); + return getDelegatePreparedStatement().executeUpdate(); } catch (final SQLException e) { handleException(e); + return 0; } } + private PreparedStatement getDelegatePreparedStatement() { + return (PreparedStatement) getDelegate(); + } + @Override - public void setShort(final int parameterIndex, final short x) throws SQLException { + public ResultSetMetaData getMetaData() throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setShort(parameterIndex, x); + return getDelegatePreparedStatement().getMetaData(); } catch (final SQLException e) { handleException(e); + throw new AssertionError(); } } @Override - public void setInt(final int parameterIndex, final int x) throws SQLException { + public java.sql.ParameterMetaData getParameterMetaData() throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setInt(parameterIndex, x); + return getDelegatePreparedStatement().getParameterMetaData(); } catch (final SQLException e) { handleException(e); + throw new AssertionError(); } } @Override - public void setLong(final int parameterIndex, final long x) throws SQLException { + public void setArray(final int i, final Array x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setLong(parameterIndex, x); + getDelegatePreparedStatement().setArray(i, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setFloat(final int parameterIndex, final float x) throws SQLException { + public void setAsciiStream(final int parameterIndex, final InputStream inputStream) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setFloat(parameterIndex, x); + getDelegatePreparedStatement().setAsciiStream(parameterIndex, inputStream); } catch (final SQLException e) { handleException(e); } } @Override - public void setDouble(final int parameterIndex, final double x) throws SQLException { + public void setAsciiStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setDouble(parameterIndex, x); + getDelegatePreparedStatement().setAsciiStream(parameterIndex, x, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setBigDecimal(final int parameterIndex, final BigDecimal x) throws SQLException { + public void setAsciiStream(final int parameterIndex, final InputStream inputStream, final long length) + throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBigDecimal(parameterIndex, x); + getDelegatePreparedStatement().setAsciiStream(parameterIndex, inputStream, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setString(final int parameterIndex, final String x) throws SQLException { + public void setBigDecimal(final int parameterIndex, final BigDecimal x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setString(parameterIndex, x); + getDelegatePreparedStatement().setBigDecimal(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setBytes(final int parameterIndex, final byte[] x) throws SQLException { + public void setBinaryStream(final int parameterIndex, final InputStream inputStream) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBytes(parameterIndex, x); + getDelegatePreparedStatement().setBinaryStream(parameterIndex, inputStream); } catch (final SQLException e) { handleException(e); } } @Override - public void setDate(final int parameterIndex, final Date x) throws SQLException { + public void setBinaryStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setDate(parameterIndex, x); + getDelegatePreparedStatement().setBinaryStream(parameterIndex, x, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setTime(final int parameterIndex, final Time x) throws SQLException { + public void setBinaryStream(final int parameterIndex, final InputStream inputStream, final long length) + throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setTime(parameterIndex, x); + getDelegatePreparedStatement().setBinaryStream(parameterIndex, inputStream, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setTimestamp(final int parameterIndex, final Timestamp x) throws SQLException { + public void setBlob(final int i, final Blob x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setTimestamp(parameterIndex, x); + getDelegatePreparedStatement().setBlob(i, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setAsciiStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { + public void setBlob(final int parameterIndex, final InputStream inputStream) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setAsciiStream(parameterIndex, x, length); + getDelegatePreparedStatement().setBlob(parameterIndex, inputStream); } catch (final SQLException e) { handleException(e); } } - /** @deprecated Use setAsciiStream(), setCharacterStream() or setNCharacterStream() */ - @Deprecated @Override - public void setUnicodeStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { + public void setBlob(final int parameterIndex, final InputStream inputStream, final long length) + throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setUnicodeStream(parameterIndex, x, length); + getDelegatePreparedStatement().setBlob(parameterIndex, inputStream, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setBinaryStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { + public void setBoolean(final int parameterIndex, final boolean x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBinaryStream(parameterIndex, x, length); + getDelegatePreparedStatement().setBoolean(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void clearParameters() throws SQLException { + public void setByte(final int parameterIndex, final byte x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().clearParameters(); + getDelegatePreparedStatement().setByte(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setObject(final int parameterIndex, final Object x, final int targetSqlType, final int scale) - throws SQLException { + public void setBytes(final int parameterIndex, final byte[] x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setObject(parameterIndex, x, targetSqlType, scale); + getDelegatePreparedStatement().setBytes(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setObject(final int parameterIndex, final Object x, final int targetSqlType) throws SQLException { + public void setCharacterStream(final int parameterIndex, final Reader reader) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setObject(parameterIndex, x, targetSqlType); + getDelegatePreparedStatement().setCharacterStream(parameterIndex, reader); } catch (final SQLException e) { handleException(e); } } @Override - public void setObject(final int parameterIndex, final Object x) throws SQLException { + public void setCharacterStream(final int parameterIndex, final Reader reader, final int length) + throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setObject(parameterIndex, x); + getDelegatePreparedStatement().setCharacterStream(parameterIndex, reader, length); } catch (final SQLException e) { handleException(e); } } @Override - public boolean execute() throws SQLException { + public void setCharacterStream(final int parameterIndex, final Reader reader, final long length) + throws SQLException { checkOpen(); - if (getConnectionInternal() != null) { - getConnectionInternal().setLastUsed(); - } try { - return getDelegatePreparedStatement().execute(); + getDelegatePreparedStatement().setCharacterStream(parameterIndex, reader, length); } catch (final SQLException e) { handleException(e); - return false; } } @Override - public void addBatch() throws SQLException { + public void setClob(final int i, final Clob x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().addBatch(); + getDelegatePreparedStatement().setClob(i, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setCharacterStream(final int parameterIndex, final Reader reader, final int length) - throws SQLException { + public void setClob(final int parameterIndex, final Reader reader) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setCharacterStream(parameterIndex, reader, length); + getDelegatePreparedStatement().setClob(parameterIndex, reader); } catch (final SQLException e) { handleException(e); } } @Override - public void setRef(final int i, final Ref x) throws SQLException { + public void setClob(final int parameterIndex, final Reader reader, final long length) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setRef(i, x); + getDelegatePreparedStatement().setClob(parameterIndex, reader, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setBlob(final int i, final Blob x) throws SQLException { + public void setDate(final int parameterIndex, final Date x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBlob(i, x); + getDelegatePreparedStatement().setDate(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setClob(final int i, final Clob x) throws SQLException { + public void setDate(final int parameterIndex, final Date x, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setClob(i, x); + getDelegatePreparedStatement().setDate(parameterIndex, x, cal); } catch (final SQLException e) { handleException(e); } } @Override - public void setArray(final int i, final Array x) throws SQLException { + public void setDouble(final int parameterIndex, final double x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setArray(i, x); + getDelegatePreparedStatement().setDouble(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public ResultSetMetaData getMetaData() throws SQLException { + public void setFloat(final int parameterIndex, final float x) throws SQLException { checkOpen(); try { - return getDelegatePreparedStatement().getMetaData(); + getDelegatePreparedStatement().setFloat(parameterIndex, x); } catch (final SQLException e) { handleException(e); - throw new AssertionError(); } } @Override - public void setDate(final int parameterIndex, final Date x, final Calendar cal) throws SQLException { + public void setInt(final int parameterIndex, final int x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setDate(parameterIndex, x, cal); + getDelegatePreparedStatement().setInt(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setTime(final int parameterIndex, final Time x, final Calendar cal) throws SQLException { + public void setLong(final int parameterIndex, final long x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setTime(parameterIndex, x, cal); + getDelegatePreparedStatement().setLong(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setTimestamp(final int parameterIndex, final Timestamp x, final Calendar cal) throws SQLException { + public void setNCharacterStream(final int parameterIndex, final Reader reader) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setTimestamp(parameterIndex, x, cal); + getDelegatePreparedStatement().setNCharacterStream(parameterIndex, reader); } catch (final SQLException e) { handleException(e); } } @Override - public void setNull(final int paramIndex, final int sqlType, final String typeName) throws SQLException { + public void setNCharacterStream(final int parameterIndex, final Reader value, final long length) + throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setNull(paramIndex, sqlType, typeName); + getDelegatePreparedStatement().setNCharacterStream(parameterIndex, value, length); } catch (final SQLException e) { handleException(e); } } - /** - * Returns a String representation of this object. - * - * @return String - */ - @SuppressWarnings("resource") @Override - public String toString() { - final Statement statement = getDelegate(); - return statement == null ? "NULL" : statement.toString(); - } - - @Override - public void setURL(final int parameterIndex, final java.net.URL x) throws SQLException { + public void setNClob(final int parameterIndex, final NClob value) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setURL(parameterIndex, x); + getDelegatePreparedStatement().setNClob(parameterIndex, value); } catch (final SQLException e) { handleException(e); } } @Override - public java.sql.ParameterMetaData getParameterMetaData() throws SQLException { + public void setNClob(final int parameterIndex, final Reader reader) throws SQLException { checkOpen(); try { - return getDelegatePreparedStatement().getParameterMetaData(); + getDelegatePreparedStatement().setNClob(parameterIndex, reader); } catch (final SQLException e) { handleException(e); - throw new AssertionError(); } } @Override - public void setRowId(final int parameterIndex, final RowId value) throws SQLException { + public void setNClob(final int parameterIndex, final Reader reader, final long length) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setRowId(parameterIndex, value); + getDelegatePreparedStatement().setNClob(parameterIndex, reader, length); } catch (final SQLException e) { handleException(e); } @@ -488,167 +478,177 @@ public class DelegatingPreparedStatement } @Override - public void setNCharacterStream(final int parameterIndex, final Reader value, final long length) - throws SQLException { + public void setNull(final int parameterIndex, final int sqlType) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setNCharacterStream(parameterIndex, value, length); + getDelegatePreparedStatement().setNull(parameterIndex, sqlType); } catch (final SQLException e) { handleException(e); } } @Override - public void setNClob(final int parameterIndex, final NClob value) throws SQLException { + public void setNull(final int paramIndex, final int sqlType, final String typeName) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setNClob(parameterIndex, value); + getDelegatePreparedStatement().setNull(paramIndex, sqlType, typeName); } catch (final SQLException e) { handleException(e); } } @Override - public void setClob(final int parameterIndex, final Reader reader, final long length) throws SQLException { + public void setObject(final int parameterIndex, final Object x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setClob(parameterIndex, reader, length); + getDelegatePreparedStatement().setObject(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setBlob(final int parameterIndex, final InputStream inputStream, final long length) - throws SQLException { + public void setObject(final int parameterIndex, final Object x, final int targetSqlType) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBlob(parameterIndex, inputStream, length); + getDelegatePreparedStatement().setObject(parameterIndex, x, targetSqlType); } catch (final SQLException e) { handleException(e); } } @Override - public void setNClob(final int parameterIndex, final Reader reader, final long length) throws SQLException { + public void setObject(final int parameterIndex, final Object x, final int targetSqlType, final int scale) + throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setNClob(parameterIndex, reader, length); + getDelegatePreparedStatement().setObject(parameterIndex, x, targetSqlType, scale); } catch (final SQLException e) { handleException(e); } } @Override - public void setSQLXML(final int parameterIndex, final SQLXML value) throws SQLException { + public void setRef(final int i, final Ref x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setSQLXML(parameterIndex, value); + getDelegatePreparedStatement().setRef(i, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setAsciiStream(final int parameterIndex, final InputStream inputStream, final long length) - throws SQLException { + public void setRowId(final int parameterIndex, final RowId value) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setAsciiStream(parameterIndex, inputStream, length); + getDelegatePreparedStatement().setRowId(parameterIndex, value); } catch (final SQLException e) { handleException(e); } } @Override - public void setBinaryStream(final int parameterIndex, final InputStream inputStream, final long length) - throws SQLException { + public void setShort(final int parameterIndex, final short x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBinaryStream(parameterIndex, inputStream, length); + getDelegatePreparedStatement().setShort(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setCharacterStream(final int parameterIndex, final Reader reader, final long length) - throws SQLException { + public void setSQLXML(final int parameterIndex, final SQLXML value) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setCharacterStream(parameterIndex, reader, length); + getDelegatePreparedStatement().setSQLXML(parameterIndex, value); } catch (final SQLException e) { handleException(e); } } @Override - public void setAsciiStream(final int parameterIndex, final InputStream inputStream) throws SQLException { + public void setString(final int parameterIndex, final String x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setAsciiStream(parameterIndex, inputStream); + getDelegatePreparedStatement().setString(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setBinaryStream(final int parameterIndex, final InputStream inputStream) throws SQLException { + public void setTime(final int parameterIndex, final Time x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBinaryStream(parameterIndex, inputStream); + getDelegatePreparedStatement().setTime(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setCharacterStream(final int parameterIndex, final Reader reader) throws SQLException { + public void setTime(final int parameterIndex, final Time x, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setCharacterStream(parameterIndex, reader); + getDelegatePreparedStatement().setTime(parameterIndex, x, cal); } catch (final SQLException e) { handleException(e); } } @Override - public void setNCharacterStream(final int parameterIndex, final Reader reader) throws SQLException { + public void setTimestamp(final int parameterIndex, final Timestamp x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setNCharacterStream(parameterIndex, reader); + getDelegatePreparedStatement().setTimestamp(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } @Override - public void setClob(final int parameterIndex, final Reader reader) throws SQLException { + public void setTimestamp(final int parameterIndex, final Timestamp x, final Calendar cal) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setClob(parameterIndex, reader); + getDelegatePreparedStatement().setTimestamp(parameterIndex, x, cal); } catch (final SQLException e) { handleException(e); } } + /** @deprecated Use setAsciiStream(), setCharacterStream() or setNCharacterStream() */ + @Deprecated @Override - public void setBlob(final int parameterIndex, final InputStream inputStream) throws SQLException { + public void setUnicodeStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setBlob(parameterIndex, inputStream); + getDelegatePreparedStatement().setUnicodeStream(parameterIndex, x, length); } catch (final SQLException e) { handleException(e); } } @Override - public void setNClob(final int parameterIndex, final Reader reader) throws SQLException { + public void setURL(final int parameterIndex, final java.net.URL x) throws SQLException { checkOpen(); try { - getDelegatePreparedStatement().setNClob(parameterIndex, reader); + getDelegatePreparedStatement().setURL(parameterIndex, x); } catch (final SQLException e) { handleException(e); } } + + /** + * Returns a String representation of this object. + * + * @return String + */ + @SuppressWarnings("resource") + @Override + public String toString() { + final Statement statement = getDelegate(); + return statement == null ? "NULL" : statement.toString(); + } }
--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org