1 16 17 package org.apache.commons.dbcp; 18 19 import java.net.URL ; 20 import java.sql.CallableStatement ; 21 import java.math.BigDecimal ; 22 import java.sql.Date ; 23 import java.sql.Time ; 24 import java.sql.Timestamp ; 25 import java.util.Map ; 26 import java.sql.Ref ; 27 import java.sql.Blob ; 28 import java.sql.Clob ; 29 import java.sql.Array ; 30 import java.util.Calendar ; 31 import java.io.InputStream ; 32 import java.io.Reader ; 33 import java.sql.SQLException ; 34 35 52 public class DelegatingCallableStatement extends DelegatingPreparedStatement 53 implements CallableStatement { 54 55 56 protected CallableStatement _stmt = null; 57 58 65 public DelegatingCallableStatement(DelegatingConnection c, 66 CallableStatement s) { 67 super(c, s); 68 _stmt = s; 69 } 70 71 public boolean equals(Object obj) { 72 CallableStatement delegate = (CallableStatement ) getInnermostDelegate(); 73 if (delegate == null) { 74 return false; 75 } 76 if (obj instanceof DelegatingCallableStatement) { 77 DelegatingCallableStatement s = (DelegatingCallableStatement) obj; 78 return delegate.equals(s.getInnermostDelegate()); 79 } 80 else { 81 return delegate.equals(obj); 82 } 83 } 84 85 86 public void setDelegate(CallableStatement s) { 87 super.setDelegate(s); 88 _stmt = s; 89 } 90 91 public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException  92 { checkOpen(); try { _stmt.registerOutParameter( parameterIndex, sqlType); } catch (SQLException e) { handleException(e); } } 93 94 public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException  95 { checkOpen(); try { _stmt.registerOutParameter( parameterIndex, sqlType, scale); } catch (SQLException e) { handleException(e); } } 96 97 public boolean wasNull() throws SQLException  98 { checkOpen(); try { return _stmt.wasNull(); } catch (SQLException e) { handleException(e); return false; } } 99 100 public String getString(int parameterIndex) throws SQLException  101 { checkOpen(); try { return _stmt.getString( parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 102 103 public boolean getBoolean(int parameterIndex) throws SQLException  104 { checkOpen(); try { return _stmt.getBoolean( parameterIndex); } catch (SQLException e) { handleException(e); return false; } } 105 106 public byte getByte(int parameterIndex) throws SQLException  107 { checkOpen(); try { return _stmt.getByte( parameterIndex); } catch (SQLException e) { handleException(e); return 0; } } 108 109 public short getShort(int parameterIndex) throws SQLException  110 { checkOpen(); try { return _stmt.getShort( parameterIndex); } catch (SQLException e) { handleException(e); return 0; } } 111 112 public int getInt(int parameterIndex) throws SQLException  113 { checkOpen(); try { return _stmt.getInt( parameterIndex); } catch (SQLException e) { handleException(e); return 0; } } 114 115 public long getLong(int parameterIndex) throws SQLException  116 { checkOpen(); try { return _stmt.getLong( parameterIndex); } catch (SQLException e) { handleException(e); return 0; } } 117 118 public float getFloat(int parameterIndex) throws SQLException  119 { checkOpen(); try { return _stmt.getFloat( parameterIndex); } catch (SQLException e) { handleException(e); return 0; } } 120 121 public double getDouble(int parameterIndex) throws SQLException  122 { checkOpen(); try { return _stmt.getDouble( parameterIndex); } catch (SQLException e) { handleException(e); return 0; } } 123 124 125 public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException  126 { checkOpen(); try { return _stmt.getBigDecimal( parameterIndex, scale); } catch (SQLException e) { handleException(e); return null; } } 127 128 public byte[] getBytes(int parameterIndex) throws SQLException  129 { checkOpen(); try { return _stmt.getBytes( parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 130 131 public Date getDate(int parameterIndex) throws SQLException  132 { checkOpen(); try { return _stmt.getDate( parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 133 134 public Time getTime(int parameterIndex) throws SQLException  135 { checkOpen(); try { return _stmt.getTime( parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 136 137 public Timestamp getTimestamp(int parameterIndex) throws SQLException  138 { checkOpen(); try { return _stmt.getTimestamp( parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 139 140 public Object getObject(int parameterIndex) throws SQLException  141 { checkOpen(); try { return _stmt.getObject( parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 142 143 public BigDecimal getBigDecimal(int parameterIndex) throws SQLException  144 { checkOpen(); try { return _stmt.getBigDecimal( parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 145 146 public Object getObject(int i, Map map) throws SQLException  147 { checkOpen(); try { return _stmt.getObject( i, map); } catch (SQLException e) { handleException(e); return null; } } 148 149 public Ref getRef(int i) throws SQLException  150 { checkOpen(); try { return _stmt.getRef( i); } catch (SQLException e) { handleException(e); return null; } } 151 152 public Blob getBlob(int i) throws SQLException  153 { checkOpen(); try { return _stmt.getBlob( i); } catch (SQLException e) { handleException(e); return null; } } 154 155 public Clob getClob(int i) throws SQLException  156 { checkOpen(); try { return _stmt.getClob( i); } catch (SQLException e) { handleException(e); return null; } } 157 158 public Array getArray(int i) throws SQLException  159 { checkOpen(); try { return _stmt.getArray( i); } catch (SQLException e) { handleException(e); return null; } } 160 161 public Date getDate(int parameterIndex, Calendar cal) throws SQLException  162 { checkOpen(); try { return _stmt.getDate( parameterIndex, cal); } catch (SQLException e) { handleException(e); return null; } } 163 164 public Time getTime(int parameterIndex, Calendar cal) throws SQLException  165 { checkOpen(); try { return _stmt.getTime( parameterIndex, cal); } catch (SQLException e) { handleException(e); return null; } } 166 167 public Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException  168 { checkOpen(); try { return _stmt.getTimestamp( parameterIndex, cal); } catch (SQLException e) { handleException(e); return null; } } 169 170 public void registerOutParameter(int paramIndex, int sqlType, String typeName) throws SQLException  171 { checkOpen(); try { _stmt.registerOutParameter( paramIndex, sqlType, typeName); } catch (SQLException e) { handleException(e); } } 172 173 176 177 178 public void registerOutParameter(String parameterName, int sqlType) throws SQLException  179 { checkOpen(); try { _stmt.registerOutParameter(parameterName, sqlType); } catch (SQLException e) { handleException(e); } } 180 181 public void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException  182 { checkOpen(); try { _stmt.registerOutParameter(parameterName, sqlType, scale); } catch (SQLException e) { handleException(e); } } 183 184 public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException  185 { checkOpen(); try { _stmt.registerOutParameter(parameterName, sqlType, typeName); } catch (SQLException e) { handleException(e); } } 186 187 public URL getURL(int parameterIndex) throws SQLException  188 { checkOpen(); try { return _stmt.getURL(parameterIndex); } catch (SQLException e) { handleException(e); return null; } } 189 190 public void setURL(String parameterName, URL val) throws SQLException  191 { checkOpen(); try { _stmt.setURL(parameterName, val); } catch (SQLException e) { handleException(e); } } 192 193 public void setNull(String parameterName, int sqlType) throws SQLException  194 { checkOpen(); try { _stmt.setNull(parameterName, sqlType); } catch (SQLException e) { handleException(e); } } 195 196 public void setBoolean(String parameterName, boolean x) throws SQLException  197 { checkOpen(); try { _stmt.setBoolean(parameterName, x); } catch (SQLException e) { handleException(e); } } 198 199 public void setByte(String parameterName, byte x) throws SQLException  200 { checkOpen(); try { _stmt.setByte(parameterName, x); } catch (SQLException e) { handleException(e); } } 201 202 public void setShort(String parameterName, short x) throws SQLException  203 { checkOpen(); try { _stmt.setShort(parameterName, x); } catch (SQLException e) { handleException(e); } } 204 205 public void setInt(String parameterName, int x) throws SQLException  206 { checkOpen(); try { _stmt.setInt(parameterName, x); } catch (SQLException e) { handleException(e); } } 207 208 public void setLong(String parameterName, long x) throws SQLException  209 { checkOpen(); try { _stmt.setLong(parameterName, x); } catch (SQLException e) { handleException(e); } } 210 211 public void setFloat(String parameterName, float x) throws SQLException  212 { checkOpen(); try { _stmt.setFloat(parameterName, x); } catch (SQLException e) { handleException(e); } } 213 214 public void setDouble(String parameterName, double x) throws SQLException  215 { checkOpen(); try { _stmt.setDouble(parameterName, x); } catch (SQLException e) { handleException(e); } } 216 217 public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException  218 { checkOpen(); try { _stmt.setBigDecimal(parameterName, x); } catch (SQLException e) { handleException(e); } } 219 220 public void setString(String parameterName, String x) throws SQLException  221 { checkOpen(); try { _stmt.setString(parameterName, x); } catch (SQLException e) { handleException(e); } } 222 223 public void setBytes(String parameterName, byte [] x) throws SQLException  224 { checkOpen(); try { _stmt.setBytes(parameterName, x); } catch (SQLException e) { handleException(e); } } 225 226 public void setDate(String parameterName, Date x) throws SQLException  227 { checkOpen(); try { _stmt.setDate(parameterName, x); } catch (SQLException e) { handleException(e); } } 228 229 public void setTime(String parameterName, Time x) throws SQLException  230 { checkOpen(); try { _stmt.setTime(parameterName, x); } catch (SQLException e) { handleException(e); } } 231 232 public void setTimestamp(String parameterName, Timestamp x) throws SQLException  233 { checkOpen(); try { _stmt.setTimestamp(parameterName, x); } catch (SQLException e) { handleException(e); } } 234 235 public void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException  236 { checkOpen(); try { _stmt.setAsciiStream(parameterName, x, length); } catch (SQLException e) { handleException(e); } } 237 238 public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException  239 { checkOpen(); try { _stmt.setBinaryStream(parameterName, x, length); } catch (SQLException e) { handleException(e); } } 240 241 public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException  242 { checkOpen(); try { _stmt.setObject(parameterName, x, targetSqlType, scale); } catch (SQLException e) { handleException(e); } } 243 244 public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException  245 { checkOpen(); try { _stmt.setObject(parameterName, x, targetSqlType); } catch (SQLException e) { handleException(e); } } 246 247 public void setObject(String parameterName, Object x) throws SQLException  248 { checkOpen(); try { _stmt.setObject(parameterName, x); } catch (SQLException e) { handleException(e); } } 249 250 public void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException  251 { checkOpen(); _stmt.setCharacterStream(parameterName, reader, length); } 252 253 public void setDate(String parameterName, Date x, Calendar cal) throws SQLException  254 { checkOpen(); try { _stmt.setDate(parameterName, x, cal); } catch (SQLException e) { handleException(e); } } 255 256 public void setTime(String parameterName, Time x, Calendar cal) throws SQLException  257 { checkOpen(); try { _stmt.setTime(parameterName, x, cal); } catch (SQLException e) { handleException(e); } } 258 259 public void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException  260 { checkOpen(); try { _stmt.setTimestamp(parameterName, x, cal); } catch (SQLException e) { handleException(e); } } 261 262 public void setNull(String parameterName, int sqlType, String typeName) throws SQLException  263 { checkOpen(); try { _stmt.setNull(parameterName, sqlType, typeName); } catch (SQLException e) { handleException(e); } } 264 265 public String getString(String parameterName) throws SQLException  266 { checkOpen(); try { return _stmt.getString(parameterName); } catch (SQLException e) { handleException(e); return null; } } 267 268 public boolean getBoolean(String parameterName) throws SQLException  269 { checkOpen(); try { return _stmt.getBoolean(parameterName); } catch (SQLException e) { handleException(e); return false; } } 270 271 public byte getByte(String parameterName) throws SQLException  272 { checkOpen(); try { return _stmt.getByte(parameterName); } catch (SQLException e) { handleException(e); return 0; } } 273 274 public short getShort(String parameterName) throws SQLException  275 { checkOpen(); try { return _stmt.getShort(parameterName); } catch (SQLException e) { handleException(e); return 0; } } 276 277 public int getInt(String parameterName) throws SQLException  278 { checkOpen(); try { return _stmt.getInt(parameterName); } catch (SQLException e) { handleException(e); return 0; } } 279 280 public long getLong(String parameterName) throws SQLException  281 { checkOpen(); try { return _stmt.getLong(parameterName); } catch (SQLException e) { handleException(e); return 0; } } 282 283 public float getFloat(String parameterName) throws SQLException  284 { checkOpen(); try { return _stmt.getFloat(parameterName); } catch (SQLException e) { handleException(e); return 0; } } 285 286 public double getDouble(String parameterName) throws SQLException  287 { checkOpen(); try { return _stmt.getDouble(parameterName); } catch (SQLException e) { handleException(e); return 0; } } 288 289 public byte[] getBytes(String parameterName) throws SQLException  290 { checkOpen(); try { return _stmt.getBytes(parameterName); } catch (SQLException e) { handleException(e); return null; } } 291 292 public Date getDate(String parameterName) throws SQLException  293 { checkOpen(); try { return _stmt.getDate(parameterName); } catch (SQLException e) { handleException(e); return null; } } 294 295 public Time getTime(String parameterName) throws SQLException  296 { checkOpen(); try { return _stmt.getTime(parameterName); } catch (SQLException e) { handleException(e); return null; } } 297 298 public Timestamp getTimestamp(String parameterName) throws SQLException  299 { checkOpen(); try { return _stmt.getTimestamp(parameterName); } catch (SQLException e) { handleException(e); return null; } } 300 301 public Object getObject(String parameterName) throws SQLException  302 { checkOpen(); try { return _stmt.getObject(parameterName); } catch (SQLException e) { handleException(e); return null; } } 303 304 public BigDecimal getBigDecimal(String parameterName) throws SQLException  305 { checkOpen(); try { return _stmt.getBigDecimal(parameterName); } catch (SQLException e) { handleException(e); return null; } } 306 307 public Object getObject(String parameterName, Map map) throws SQLException  308 { checkOpen(); try { return _stmt.getObject(parameterName, map); } catch (SQLException e) { handleException(e); return null; } } 309 310 public Ref getRef(String parameterName) throws SQLException  311 { checkOpen(); try { return _stmt.getRef(parameterName); } catch (SQLException e) { handleException(e); return null; } } 312 313 public Blob getBlob(String parameterName) throws SQLException  314 { checkOpen(); try { return _stmt.getBlob(parameterName); } catch (SQLException e) { handleException(e); return null; } } 315 316 public Clob getClob(String parameterName) throws SQLException  317 { checkOpen(); try { return _stmt.getClob(parameterName); } catch (SQLException e) { handleException(e); return null; } } 318 319 public Array getArray(String parameterName) throws SQLException  320 { checkOpen(); try { return _stmt.getArray(parameterName); } catch (SQLException e) { handleException(e); return null; } } 321 322 public Date getDate(String parameterName, Calendar cal) throws SQLException  323 { checkOpen(); try { return _stmt.getDate(parameterName, cal); } catch (SQLException e) { handleException(e); return null; } } 324 325 public Time getTime(String parameterName, Calendar cal) throws SQLException  326 { checkOpen(); try { return _stmt.getTime(parameterName, cal); } catch (SQLException e) { handleException(e); return null; } } 327 328 public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException  329 { checkOpen(); try { return _stmt.getTimestamp(parameterName, cal); } catch (SQLException e) { handleException(e); return null; } } 330 331 public URL getURL(String parameterName) throws SQLException  332 { checkOpen(); try { return _stmt.getURL(parameterName); } catch (SQLException e) { handleException(e); return null; } } 333 334 335 } | Popular Tags |