From 9a826bd41de8158a02f4315d81c6acfdcfdd1cb5 Mon Sep 17 00:00:00 2001 From: wenshao Date: Wed, 29 Jun 2011 08:17:11 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ExceptionSorter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.alibabatech.com/svn/druid/trunk@306 b9813039-fb51-4c41-a8b9-e21c2acb5095 --- .../druid/pool/PoolableCallableStatement.java | 666 +++++++++++++++--- .../druid/pool/PoolableConnection.java | 22 +- .../druid/pool/PoolablePreparedStatement.java | 336 +++++++-- .../alibaba/druid/pool/PoolableStatement.java | 238 +++++-- 4 files changed, 1043 insertions(+), 219 deletions(-) diff --git a/src/main/java/com/alibaba/druid/pool/PoolableCallableStatement.java b/src/main/java/com/alibaba/druid/pool/PoolableCallableStatement.java index 17cc46fd15..2a6272c243 100644 --- a/src/main/java/com/alibaba/druid/pool/PoolableCallableStatement.java +++ b/src/main/java/com/alibaba/druid/pool/PoolableCallableStatement.java @@ -43,558 +43,1002 @@ public class PoolableCallableStatement extends PoolablePreparedStatement impleme @Override public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { - stmt.registerOutParameter(parameterIndex, sqlType); + try { + stmt.registerOutParameter(parameterIndex, sqlType); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException { - stmt.registerOutParameter(parameterIndex, sqlType, scale); + try { + stmt.registerOutParameter(parameterIndex, sqlType, scale); + } catch (Throwable t) { + throw checkException(t); + } } @Override public boolean wasNull() throws SQLException { - return stmt.wasNull(); + try { + return stmt.wasNull(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public String getString(int parameterIndex) throws SQLException { - return stmt.getString(parameterIndex); + try { + return stmt.getString(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public boolean getBoolean(int parameterIndex) throws SQLException { - return stmt.getBoolean(parameterIndex); + try { + return stmt.getBoolean(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public byte getByte(int parameterIndex) throws SQLException { - return stmt.getByte(parameterIndex); + try { + return stmt.getByte(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public short getShort(int parameterIndex) throws SQLException { - return stmt.getShort(parameterIndex); + try { + return stmt.getShort(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public int getInt(int parameterIndex) throws SQLException { - return stmt.getInt(parameterIndex); + try { + return stmt.getInt(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public long getLong(int parameterIndex) throws SQLException { - return stmt.getLong(parameterIndex); + try { + return stmt.getLong(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public float getFloat(int parameterIndex) throws SQLException { - return stmt.getFloat(parameterIndex); + try { + return stmt.getFloat(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public double getDouble(int parameterIndex) throws SQLException { - return stmt.getDouble(parameterIndex); + try { + return stmt.getDouble(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override @Deprecated public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException { - return stmt.getBigDecimal(parameterIndex, scale); + try { + return stmt.getBigDecimal(parameterIndex, scale); + } catch (Throwable t) { + throw checkException(t); + } } @Override public byte[] getBytes(int parameterIndex) throws SQLException { - return stmt.getBytes(parameterIndex); + try { + return stmt.getBytes(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Date getDate(int parameterIndex) throws SQLException { - return stmt.getDate(parameterIndex); + try { + return stmt.getDate(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Time getTime(int parameterIndex) throws SQLException { - return stmt.getTime(parameterIndex); + try { + return stmt.getTime(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Timestamp getTimestamp(int parameterIndex) throws SQLException { - return stmt.getTimestamp(parameterIndex); + try { + return stmt.getTimestamp(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Object getObject(int parameterIndex) throws SQLException { - return stmt.getObject(parameterIndex); + try { + return stmt.getObject(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public BigDecimal getBigDecimal(int parameterIndex) throws SQLException { - return stmt.getBigDecimal(parameterIndex); + try { + return stmt.getBigDecimal(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Object getObject(int parameterIndex, java.util.Map> map) throws SQLException { - return stmt.getObject(parameterIndex, map); + try { + return stmt.getObject(parameterIndex, map); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Ref getRef(int parameterIndex) throws SQLException { - return stmt.getRef(parameterIndex); + try { + return stmt.getRef(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Blob getBlob(int parameterIndex) throws SQLException { - return stmt.getBlob(parameterIndex); + try { + return stmt.getBlob(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Clob getClob(int parameterIndex) throws SQLException { - return stmt.getClob(parameterIndex); + try { + return stmt.getClob(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Array getArray(int parameterIndex) throws SQLException { - return stmt.getArray(parameterIndex); + try { + return stmt.getArray(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Date getDate(int parameterIndex, Calendar cal) throws SQLException { - return stmt.getDate(parameterIndex, cal); + try { + return stmt.getDate(parameterIndex, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Time getTime(int parameterIndex, Calendar cal) throws SQLException { - return stmt.getTime(parameterIndex, cal); + try { + return stmt.getTime(parameterIndex, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException { - return stmt.getTimestamp(parameterIndex, cal); + try { + return stmt.getTimestamp(parameterIndex, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException { - stmt.registerOutParameter(parameterIndex, sqlType, typeName); + try { + stmt.registerOutParameter(parameterIndex, sqlType, typeName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void registerOutParameter(String parameterName, int sqlType) throws SQLException { - stmt.registerOutParameter(parameterName, sqlType); + try { + stmt.registerOutParameter(parameterName, sqlType); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException { - stmt.registerOutParameter(parameterName, sqlType, scale); + try { + stmt.registerOutParameter(parameterName, sqlType, scale); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException { - stmt.registerOutParameter(parameterName, sqlType, typeName); + try { + stmt.registerOutParameter(parameterName, sqlType, typeName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.net.URL getURL(int parameterIndex) throws SQLException { - return stmt.getURL(parameterIndex); + try { + return stmt.getURL(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setURL(String parameterName, java.net.URL val) throws SQLException { - stmt.setURL(parameterName, val); + try { + stmt.setURL(parameterName, val); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNull(String parameterName, int sqlType) throws SQLException { - stmt.setNull(parameterName, sqlType); + try { + stmt.setNull(parameterName, sqlType); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBoolean(String parameterName, boolean x) throws SQLException { - stmt.setBoolean(parameterName, x); + try { + stmt.setBoolean(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setByte(String parameterName, byte x) throws SQLException { - stmt.setByte(parameterName, x); + try { + stmt.setByte(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setShort(String parameterName, short x) throws SQLException { - stmt.setShort(parameterName, x); + try { + stmt.setShort(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setInt(String parameterName, int x) throws SQLException { - stmt.setInt(parameterName, x); + try { + stmt.setInt(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setLong(String parameterName, long x) throws SQLException { - stmt.setLong(parameterName, x); + try { + stmt.setLong(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setFloat(String parameterName, float x) throws SQLException { - stmt.setFloat(parameterName, x); + try { + stmt.setFloat(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setDouble(String parameterName, double x) throws SQLException { - stmt.setDouble(parameterName, x); + try { + stmt.setDouble(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException { - stmt.setBigDecimal(parameterName, x); + try { + stmt.setBigDecimal(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setString(String parameterName, String x) throws SQLException { - stmt.setString(parameterName, x); + try { + stmt.setString(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBytes(String parameterName, byte x[]) throws SQLException { - stmt.setBytes(parameterName, x); + try { + stmt.setBytes(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setDate(String parameterName, java.sql.Date x) throws SQLException { - stmt.setDate(parameterName, x); + try { + stmt.setDate(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTime(String parameterName, java.sql.Time x) throws SQLException { - stmt.setTime(parameterName, x); + try { + stmt.setTime(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTimestamp(String parameterName, java.sql.Timestamp x) throws SQLException { - stmt.setTimestamp(parameterName, x); + try { + stmt.setTimestamp(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setAsciiStream(String parameterName, java.io.InputStream x, int length) throws SQLException { - stmt.setAsciiStream(parameterName, x, length); + try { + stmt.setAsciiStream(parameterName, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBinaryStream(String parameterName, java.io.InputStream x, int length) throws SQLException { - stmt.setBinaryStream(parameterName, x, length); + try { + stmt.setBinaryStream(parameterName, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException { - stmt.setObject(parameterName, x, targetSqlType, scale); + try { + stmt.setObject(parameterName, x, targetSqlType, scale); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException { - stmt.setObject(parameterName, x, targetSqlType); + try { + stmt.setObject(parameterName, x, targetSqlType); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setObject(String parameterName, Object x) throws SQLException { - stmt.setObject(parameterName, x); + try { + stmt.setObject(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setCharacterStream(String parameterName, java.io.Reader reader, int length) throws SQLException { - stmt.setCharacterStream(parameterName, reader, length); + try { + stmt.setCharacterStream(parameterName, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setDate(String parameterName, java.sql.Date x, Calendar cal) throws SQLException { - stmt.setDate(parameterName, x, cal); + try { + stmt.setDate(parameterName, x, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTime(String parameterName, java.sql.Time x, Calendar cal) throws SQLException { - stmt.setTime(parameterName, x, cal); + try { + stmt.setTime(parameterName, x, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal) throws SQLException { - stmt.setTimestamp(parameterName, x, cal); + try { + stmt.setTimestamp(parameterName, x, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNull(String parameterName, int sqlType, String typeName) throws SQLException { - stmt.setNull(parameterName, sqlType, typeName); + try { + stmt.setNull(parameterName, sqlType, typeName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public String getString(String parameterName) throws SQLException { - return stmt.getString(parameterName); + try { + return stmt.getString(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public boolean getBoolean(String parameterName) throws SQLException { - return stmt.getBoolean(parameterName); + try { + return stmt.getBoolean(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public byte getByte(String parameterName) throws SQLException { - return stmt.getByte(parameterName); + try { + return stmt.getByte(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public short getShort(String parameterName) throws SQLException { - return stmt.getShort(parameterName); + try { + return stmt.getShort(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public int getInt(String parameterName) throws SQLException { - return stmt.getInt(parameterName); + try { + return stmt.getInt(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public long getLong(String parameterName) throws SQLException { - return stmt.getLong(parameterName); + try { + return stmt.getLong(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public float getFloat(String parameterName) throws SQLException { - return stmt.getFloat(parameterName); + try { + return stmt.getFloat(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public double getDouble(String parameterName) throws SQLException { - return stmt.getDouble(parameterName); + try { + return stmt.getDouble(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public byte[] getBytes(String parameterName) throws SQLException { - return stmt.getBytes(parameterName); + try { + return stmt.getBytes(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Date getDate(String parameterName) throws SQLException { - return stmt.getDate(parameterName); + try { + return stmt.getDate(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Time getTime(String parameterName) throws SQLException { - return stmt.getTime(parameterName); + try { + return stmt.getTime(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Timestamp getTimestamp(String parameterName) throws SQLException { - return stmt.getTimestamp(parameterName); + try { + return stmt.getTimestamp(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Object getObject(String parameterName) throws SQLException { - return stmt.getObject(parameterName); + try { + return stmt.getObject(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public BigDecimal getBigDecimal(String parameterName) throws SQLException { - return stmt.getBigDecimal(parameterName); + try { + return stmt.getBigDecimal(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Object getObject(String parameterName, java.util.Map> map) throws SQLException { - return stmt.getObject(parameterName, map); + try { + return stmt.getObject(parameterName, map); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Ref getRef(String parameterName) throws SQLException { - return stmt.getRef(parameterName); + try { + return stmt.getRef(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Blob getBlob(String parameterName) throws SQLException { - return stmt.getBlob(parameterName); + try { + return stmt.getBlob(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Clob getClob(String parameterName) throws SQLException { - return stmt.getClob(parameterName); + try { + return stmt.getClob(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public Array getArray(String parameterName) throws SQLException { - return stmt.getArray(parameterName); + try { + return stmt.getArray(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Date getDate(String parameterName, Calendar cal) throws SQLException { - return stmt.getDate(parameterName, cal); + try { + return stmt.getDate(parameterName, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Time getTime(String parameterName, Calendar cal) throws SQLException { - return stmt.getTime(parameterName, cal); + try { + return stmt.getTime(parameterName, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.sql.Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException { - return stmt.getTimestamp(parameterName, cal); + try { + return stmt.getTimestamp(parameterName, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.net.URL getURL(String parameterName) throws SQLException { - return stmt.getURL(parameterName); + try { + return stmt.getURL(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public RowId getRowId(int parameterIndex) throws SQLException { - return stmt.getRowId(parameterIndex); + try { + return stmt.getRowId(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public RowId getRowId(String parameterName) throws SQLException { - return stmt.getRowId(parameterName); + try { + return stmt.getRowId(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setRowId(String parameterName, RowId x) throws SQLException { - stmt.setRowId(parameterName, x); + try { + stmt.setRowId(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNString(String parameterName, String value) throws SQLException { - stmt.setNString(parameterName, value); + try { + stmt.setNString(parameterName, value); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException { - stmt.setNCharacterStream(parameterName, value, length); + try { + stmt.setNCharacterStream(parameterName, value, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNClob(String parameterName, NClob value) throws SQLException { - stmt.setNClob(parameterName, value); + try { + stmt.setNClob(parameterName, value); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setClob(String parameterName, Reader reader, long length) throws SQLException { - stmt.setClob(parameterName, reader, length); + try { + stmt.setClob(parameterName, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException { - stmt.setBlob(parameterName, inputStream, length); + try { + stmt.setBlob(parameterName, inputStream, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNClob(String parameterName, Reader reader, long length) throws SQLException { - stmt.setNClob(parameterName, reader, length); + try { + stmt.setNClob(parameterName, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public NClob getNClob(int parameterIndex) throws SQLException { - return stmt.getNClob(parameterIndex); + try { + return stmt.getNClob(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public NClob getNClob(String parameterName) throws SQLException { - return stmt.getNClob(parameterName); + try { + return stmt.getNClob(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { - stmt.setSQLXML(parameterName, xmlObject); + try { + stmt.setSQLXML(parameterName, xmlObject); + } catch (Throwable t) { + throw checkException(t); + } } @Override public SQLXML getSQLXML(int parameterIndex) throws SQLException { - return stmt.getSQLXML(parameterIndex); + try { + return stmt.getSQLXML(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public SQLXML getSQLXML(String parameterName) throws SQLException { - return stmt.getSQLXML(parameterName); + try { + return stmt.getSQLXML(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public String getNString(int parameterIndex) throws SQLException { - return stmt.getNString(parameterIndex); + try { + return stmt.getNString(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public String getNString(String parameterName) throws SQLException { - return stmt.getNString(parameterName); + try { + return stmt.getNString(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.io.Reader getNCharacterStream(int parameterIndex) throws SQLException { - return stmt.getNCharacterStream(parameterIndex); + try { + return stmt.getNCharacterStream(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.io.Reader getNCharacterStream(String parameterName) throws SQLException { - return stmt.getNCharacterStream(parameterName); + try { + return stmt.getNCharacterStream(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.io.Reader getCharacterStream(int parameterIndex) throws SQLException { - return stmt.getCharacterStream(parameterIndex); + try { + return stmt.getCharacterStream(parameterIndex); + } catch (Throwable t) { + throw checkException(t); + } } @Override public java.io.Reader getCharacterStream(String parameterName) throws SQLException { - return stmt.getCharacterStream(parameterName); + try { + return stmt.getCharacterStream(parameterName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBlob(String parameterName, Blob x) throws SQLException { - stmt.setBlob(parameterName, x); + try { + stmt.setBlob(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setClob(String parameterName, Clob x) throws SQLException { - stmt.setClob(parameterName, x); + try { + stmt.setClob(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setAsciiStream(String parameterName, java.io.InputStream x, long length) throws SQLException { - stmt.setAsciiStream(parameterName, x, length); + try { + stmt.setAsciiStream(parameterName, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBinaryStream(String parameterName, java.io.InputStream x, long length) throws SQLException { - stmt.setBinaryStream(parameterName, x, length); + try { + stmt.setBinaryStream(parameterName, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setCharacterStream(String parameterName, java.io.Reader reader, long length) throws SQLException { - stmt.setCharacterStream(parameterName, reader, length); + try { + stmt.setCharacterStream(parameterName, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setAsciiStream(String parameterName, java.io.InputStream x) throws SQLException { - stmt.setAsciiStream(parameterName, x); + try { + stmt.setAsciiStream(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBinaryStream(String parameterName, java.io.InputStream x) throws SQLException { - stmt.setBinaryStream(parameterName, x); + try { + stmt.setBinaryStream(parameterName, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setCharacterStream(String parameterName, java.io.Reader reader) throws SQLException { - stmt.setCharacterStream(parameterName, reader); + try { + stmt.setCharacterStream(parameterName, reader); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNCharacterStream(String parameterName, Reader value) throws SQLException { - stmt.setNCharacterStream(parameterName, value); + try { + stmt.setNCharacterStream(parameterName, value); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setClob(String parameterName, Reader reader) throws SQLException { - stmt.setClob(parameterName, reader); + try { + stmt.setClob(parameterName, reader); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBlob(String parameterName, InputStream inputStream) throws SQLException { - stmt.setBlob(parameterName, inputStream); + try { + stmt.setBlob(parameterName, inputStream); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNClob(String parameterName, Reader reader) throws SQLException { - stmt.setNClob(parameterName, reader); + try { + stmt.setNClob(parameterName, reader); + } catch (Throwable t) { + throw checkException(t); + } } } diff --git a/src/main/java/com/alibaba/druid/pool/PoolableConnection.java b/src/main/java/com/alibaba/druid/pool/PoolableConnection.java index 38ef6bf3b6..854a609535 100644 --- a/src/main/java/com/alibaba/druid/pool/PoolableConnection.java +++ b/src/main/java/com/alibaba/druid/pool/PoolableConnection.java @@ -54,6 +54,13 @@ public class PoolableConnection implements PooledConnection, Connection { this.holder = holder; } + protected SQLException checkException(Throwable t) throws SQLException { + // if (mc != null) mc.connectionError(t); + // if (t instanceof SQLException) throw (SQLException) t; + // else throw new NestedSQLException("Error", t); + return null; + } + void closePoolableStatement(PoolablePreparedStatement stmt) throws SQLException { PreparedStatement rawStatement = stmt.getRawPreparedStatement(); @@ -118,7 +125,8 @@ public class PoolableConnection implements PooledConnection, Connection { } @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { checkOpen(); if (holder.isPoolPreparedStatements()) { @@ -142,7 +150,8 @@ public class PoolableConnection implements PooledConnection, Connection { } @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { + public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { checkOpen(); if (holder.isPoolPreparedStatements()) { @@ -155,7 +164,8 @@ public class PoolableConnection implements PooledConnection, Connection { return poolableStatement; } - PreparedStatement stmt = conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + PreparedStatement stmt = conn.prepareStatement(sql, resultSetType, resultSetConcurrency, + resultSetHoldability); holder.getDataSource().initStatement(stmt); @@ -264,7 +274,8 @@ public class PoolableConnection implements PooledConnection, Connection { } @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { checkOpen(); if (holder.isPoolPreparedStatements()) { @@ -328,7 +339,8 @@ public class PoolableConnection implements PooledConnection, Connection { } @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { + public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) + throws SQLException { checkOpen(); Statement stmt = conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); diff --git a/src/main/java/com/alibaba/druid/pool/PoolablePreparedStatement.java b/src/main/java/com/alibaba/druid/pool/PoolablePreparedStatement.java index d18daca0bd..25c86ad363 100644 --- a/src/main/java/com/alibaba/druid/pool/PoolablePreparedStatement.java +++ b/src/main/java/com/alibaba/druid/pool/PoolablePreparedStatement.java @@ -73,283 +73,503 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep @Override public ResultSet executeQuery() throws SQLException { - ResultSet rs = stmt.executeQuery(); + try { + ResultSet rs = stmt.executeQuery(); - PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); - resultSetTrace.add(poolableResultSet); + PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); + resultSetTrace.add(poolableResultSet); - return poolableResultSet; + return poolableResultSet; + } catch (Throwable t) { + throw checkException(t); + } } @Override public int executeUpdate() throws SQLException { - return stmt.executeUpdate(); + try { + return stmt.executeUpdate(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNull(int parameterIndex, int sqlType) throws SQLException { - stmt.setNull(parameterIndex, sqlType); + try { + stmt.setNull(parameterIndex, sqlType); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBoolean(int parameterIndex, boolean x) throws SQLException { - stmt.setBoolean(parameterIndex, x); + try { + stmt.setBoolean(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setByte(int parameterIndex, byte x) throws SQLException { - stmt.setByte(parameterIndex, x); + try { + stmt.setByte(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setShort(int parameterIndex, short x) throws SQLException { - stmt.setShort(parameterIndex, x); + try { + stmt.setShort(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setInt(int parameterIndex, int x) throws SQLException { - stmt.setInt(parameterIndex, x); + try { + stmt.setInt(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setLong(int parameterIndex, long x) throws SQLException { - stmt.setLong(parameterIndex, x); + try { + stmt.setLong(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setFloat(int parameterIndex, float x) throws SQLException { - stmt.setFloat(parameterIndex, x); + try { + stmt.setFloat(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setDouble(int parameterIndex, double x) throws SQLException { - stmt.setDouble(parameterIndex, x); + try { + stmt.setDouble(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { - stmt.setBigDecimal(parameterIndex, x); + try { + stmt.setBigDecimal(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setString(int parameterIndex, String x) throws SQLException { - stmt.setString(parameterIndex, x); + try { + stmt.setString(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBytes(int parameterIndex, byte[] x) throws SQLException { - stmt.setBytes(parameterIndex, x); + try { + stmt.setBytes(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setDate(int parameterIndex, Date x) throws SQLException { - stmt.setDate(parameterIndex, x); + try { + stmt.setDate(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTime(int parameterIndex, Time x) throws SQLException { - stmt.setTime(parameterIndex, x); + try { + stmt.setTime(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { - stmt.setTimestamp(parameterIndex, x); + try { + stmt.setTimestamp(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { - stmt.setAsciiStream(parameterIndex, x, length); + try { + stmt.setAsciiStream(parameterIndex, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override @Deprecated public void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException { - stmt.setUnicodeStream(parameterIndex, x, length); + try { + stmt.setUnicodeStream(parameterIndex, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { - stmt.setBinaryStream(parameterIndex, x, length); + try { + stmt.setBinaryStream(parameterIndex, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void clearParameters() throws SQLException { - stmt.clearParameters(); + try { + stmt.clearParameters(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { - stmt.setObject(parameterIndex, x, targetSqlType); + try { + stmt.setObject(parameterIndex, x, targetSqlType); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setObject(int parameterIndex, Object x) throws SQLException { - stmt.setObject(parameterIndex, x); + try { + stmt.setObject(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public boolean execute() throws SQLException { - return stmt.execute(); + try { + return stmt.execute(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void addBatch() throws SQLException { - stmt.addBatch(); + try { + stmt.addBatch(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException { - stmt.setCharacterStream(parameterIndex, reader, length); + try { + stmt.setCharacterStream(parameterIndex, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setRef(int parameterIndex, Ref x) throws SQLException { - stmt.setRef(parameterIndex, x); + try { + stmt.setRef(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBlob(int parameterIndex, Blob x) throws SQLException { - stmt.setBlob(parameterIndex, x); + try { + stmt.setBlob(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setClob(int parameterIndex, Clob x) throws SQLException { - stmt.setClob(parameterIndex, x); + try { + stmt.setClob(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setArray(int parameterIndex, Array x) throws SQLException { - stmt.setArray(parameterIndex, x); + try { + stmt.setArray(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public ResultSetMetaData getMetaData() throws SQLException { - return stmt.getMetaData(); + try { + return stmt.getMetaData(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { - stmt.setDate(parameterIndex, x, cal); + try { + stmt.setDate(parameterIndex, x, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { - stmt.setTime(parameterIndex, x, cal); + try { + stmt.setTime(parameterIndex, x, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { - stmt.setTimestamp(parameterIndex, x, cal); + try { + stmt.setTimestamp(parameterIndex, x, cal); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { - stmt.setNull(parameterIndex, sqlType, typeName); + try { + stmt.setNull(parameterIndex, sqlType, typeName); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setURL(int parameterIndex, URL x) throws SQLException { - stmt.setURL(parameterIndex, x); + try { + stmt.setURL(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public ParameterMetaData getParameterMetaData() throws SQLException { - return stmt.getParameterMetaData(); + try { + return stmt.getParameterMetaData(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setRowId(int parameterIndex, RowId x) throws SQLException { - stmt.setRowId(parameterIndex, x); + try { + stmt.setRowId(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNString(int parameterIndex, String value) throws SQLException { - stmt.setNString(parameterIndex, value); + try { + stmt.setNString(parameterIndex, value); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { - stmt.setNCharacterStream(parameterIndex, value, length); + try { + stmt.setNCharacterStream(parameterIndex, value, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNClob(int parameterIndex, NClob value) throws SQLException { - stmt.setNClob(parameterIndex, value); + try { + stmt.setNClob(parameterIndex, value); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { - stmt.setClob(parameterIndex, reader, length); + try { + stmt.setClob(parameterIndex, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException { - stmt.setBlob(parameterIndex, inputStream, length); + try { + stmt.setBlob(parameterIndex, inputStream, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { - stmt.setNClob(parameterIndex, reader, length); + try { + stmt.setNClob(parameterIndex, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { - stmt.setSQLXML(parameterIndex, xmlObject); + try { + stmt.setSQLXML(parameterIndex, xmlObject); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException { - stmt.setObject(parameterIndex, x, targetSqlType, scaleOrLength); + try { + stmt.setObject(parameterIndex, x, targetSqlType, scaleOrLength); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { - stmt.setAsciiStream(parameterIndex, x, length); + try { + stmt.setAsciiStream(parameterIndex, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException { - stmt.setBinaryStream(parameterIndex, x, length); + try { + stmt.setBinaryStream(parameterIndex, x, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException { - stmt.setCharacterStream(parameterIndex, reader, length); + try { + stmt.setCharacterStream(parameterIndex, reader, length); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { - stmt.setAsciiStream(parameterIndex, x); + try { + stmt.setAsciiStream(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { - stmt.setBinaryStream(parameterIndex, x); + try { + stmt.setBinaryStream(parameterIndex, x); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { - stmt.setCharacterStream(parameterIndex, reader); + try { + stmt.setCharacterStream(parameterIndex, reader); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { - stmt.setNCharacterStream(parameterIndex, value); + try { + stmt.setNCharacterStream(parameterIndex, value); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setClob(int parameterIndex, Reader reader) throws SQLException { - stmt.setClob(parameterIndex, reader); + try { + stmt.setClob(parameterIndex, reader); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { - stmt.setBlob(parameterIndex, inputStream); + try { + stmt.setBlob(parameterIndex, inputStream); + } catch (Throwable t) { + throw checkException(t); + } } @Override public void setNClob(int parameterIndex, Reader reader) throws SQLException { - stmt.setNClob(parameterIndex, reader); + try { + stmt.setNClob(parameterIndex, reader); + } catch (Throwable t) { + throw checkException(t); + } } static class PreparedStatementKey { diff --git a/src/main/java/com/alibaba/druid/pool/PoolableStatement.java b/src/main/java/com/alibaba/druid/pool/PoolableStatement.java index e5d3db7bef..1f219524d9 100644 --- a/src/main/java/com/alibaba/druid/pool/PoolableStatement.java +++ b/src/main/java/com/alibaba/druid/pool/PoolableStatement.java @@ -37,6 +37,10 @@ public class PoolableStatement extends PoolableWrapper implements Statement { this.stmt = stmt; } + protected SQLException checkException(Throwable error) throws SQLException { + return conn.checkException(error); + } + public PoolableConnection getPoolableConnection() { return conn; } @@ -60,17 +64,25 @@ public class PoolableStatement extends PoolableWrapper implements Statement { @Override public final ResultSet executeQuery(String sql) throws SQLException { - ResultSet rs = stmt.executeQuery(sql); + try { + ResultSet rs = stmt.executeQuery(sql); - PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); - resultSetTrace.add(poolableResultSet); + PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); + resultSetTrace.add(poolableResultSet); - return poolableResultSet; + return poolableResultSet; + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int executeUpdate(String sql) throws SQLException { - return stmt.executeUpdate(sql); + try { + return stmt.executeUpdate(sql); + } catch (Throwable t) { + throw checkException(t); + } } @Override @@ -84,127 +96,223 @@ public class PoolableStatement extends PoolableWrapper implements Statement { @Override public final int getMaxFieldSize() throws SQLException { - return stmt.getMaxFieldSize(); + try { + return stmt.getMaxFieldSize(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void setMaxFieldSize(int max) throws SQLException { - stmt.setMaxFieldSize(max); + try { + stmt.setMaxFieldSize(max); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getMaxRows() throws SQLException { - return stmt.getMaxRows(); + try { + return stmt.getMaxRows(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void setMaxRows(int max) throws SQLException { - stmt.setMaxRows(max); + try { + stmt.setMaxRows(max); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void setEscapeProcessing(boolean enable) throws SQLException { - stmt.setEscapeProcessing(enable); + try { + stmt.setEscapeProcessing(enable); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getQueryTimeout() throws SQLException { - return stmt.getQueryTimeout(); + try { + return stmt.getQueryTimeout(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void setQueryTimeout(int seconds) throws SQLException { - stmt.setQueryTimeout(seconds); + try { + stmt.setQueryTimeout(seconds); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void cancel() throws SQLException { - stmt.cancel(); + try { + stmt.cancel(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final SQLWarning getWarnings() throws SQLException { - return stmt.getWarnings(); + try { + return stmt.getWarnings(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void clearWarnings() throws SQLException { - stmt.clearWarnings(); + try { + stmt.clearWarnings(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void setCursorName(String name) throws SQLException { - stmt.setCursorName(name); + try { + stmt.setCursorName(name); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final boolean execute(String sql) throws SQLException { - return stmt.execute(sql); + try { + return stmt.execute(sql); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final ResultSet getResultSet() throws SQLException { - ResultSet rs = stmt.getResultSet(); + try { + ResultSet rs = stmt.getResultSet(); - PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); - resultSetTrace.add(poolableResultSet); + PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); + resultSetTrace.add(poolableResultSet); - return poolableResultSet; + return poolableResultSet; + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getUpdateCount() throws SQLException { - return stmt.getUpdateCount(); + try { + return stmt.getUpdateCount(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final boolean getMoreResults() throws SQLException { - return stmt.getMoreResults(); + try { + return stmt.getMoreResults(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void setFetchDirection(int direction) throws SQLException { - stmt.setFetchDirection(direction); + try { + stmt.setFetchDirection(direction); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getFetchDirection() throws SQLException { - return stmt.getFetchDirection(); + try { + return stmt.getFetchDirection(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void setFetchSize(int rows) throws SQLException { - stmt.setFetchSize(rows); + try { + stmt.setFetchSize(rows); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getFetchSize() throws SQLException { - return stmt.getFetchSize(); + try { + return stmt.getFetchSize(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getResultSetConcurrency() throws SQLException { - return stmt.getResultSetConcurrency(); + try { + return stmt.getResultSetConcurrency(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getResultSetType() throws SQLException { - return stmt.getResultSetType(); + try { + return stmt.getResultSetType(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void addBatch(String sql) throws SQLException { - stmt.addBatch(sql); + try { + stmt.addBatch(sql); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final void clearBatch() throws SQLException { - stmt.clearBatch(); + try { + stmt.clearBatch(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int[] executeBatch() throws SQLException { - return stmt.executeBatch(); + try { + return stmt.executeBatch(); + } catch (Throwable t) { + throw checkException(t); + } } @Override @@ -214,58 +322,98 @@ public class PoolableStatement extends PoolableWrapper implements Statement { @Override public final boolean getMoreResults(int current) throws SQLException { - return stmt.getMoreResults(current); + try { + return stmt.getMoreResults(current); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final ResultSet getGeneratedKeys() throws SQLException { - ResultSet rs = stmt.getGeneratedKeys(); + try { + ResultSet rs = stmt.getGeneratedKeys(); - PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); + PoolableResultSet poolableResultSet = new PoolableResultSet(this, rs); - resultSetTrace.add(poolableResultSet); + resultSetTrace.add(poolableResultSet); - return poolableResultSet; + return poolableResultSet; + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { - return stmt.executeUpdate(sql, autoGeneratedKeys); + try { + return stmt.executeUpdate(sql, autoGeneratedKeys); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int executeUpdate(String sql, int columnIndexes[]) throws SQLException { - return stmt.executeUpdate(sql, columnIndexes); + try { + return stmt.executeUpdate(sql, columnIndexes); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int executeUpdate(String sql, String columnNames[]) throws SQLException { - return stmt.executeUpdate(sql, columnNames); + try { + return stmt.executeUpdate(sql, columnNames); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException { - return stmt.execute(sql, autoGeneratedKeys); + try { + return stmt.execute(sql, autoGeneratedKeys); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final boolean execute(String sql, int columnIndexes[]) throws SQLException { - return stmt.execute(sql, columnIndexes); + try { + return stmt.execute(sql, columnIndexes); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final boolean execute(String sql, String columnNames[]) throws SQLException { - return stmt.execute(sql, columnNames); + try { + return stmt.execute(sql, columnNames); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final int getResultSetHoldability() throws SQLException { - return stmt.getResultSetHoldability(); + try { + return stmt.getResultSetHoldability(); + } catch (Throwable t) { + throw checkException(t); + } } @Override public final boolean isClosed() throws SQLException { - return stmt.isClosed(); + try { + return stmt.isClosed(); + } catch (Throwable t) { + throw checkException(t); + } } @Override