preparedstatementwrapper.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 1,116 行 · 第 1/2 页

JAVA
1,116
字号
/* * Copyright (c) 1998-2005 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty * of NON-INFRINGEMENT.  See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the *   Free SoftwareFoundation, Inc. *   59 Temple Place, Suite 330 *   Boston, MA 02111-1307  USA * * @author Sam */package com.caucho.tools.profiler;import java.io.InputStream;import java.io.Reader;import java.math.BigDecimal;import java.net.URL;import java.sql.*;import java.util.Calendar;public class PreparedStatementWrapper  implements PreparedStatement{  private final PreparedStatement _preparedStatement;  private ProfilerPoint _profilerPoint;  public PreparedStatementWrapper(ProfilerPoint profilerPoint,                                  PreparedStatement preparedStatement)  {    _profilerPoint = profilerPoint;    _preparedStatement = preparedStatement;  }  public ResultSet executeQuery()    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      return _preparedStatement.executeQuery();    }    finally {      profiler.finish();    }  }  public int executeUpdate()    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      return _preparedStatement.executeUpdate();    }    finally {      profiler.finish();    }  }  public void setNull(int parameterIndex, int sqlType)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setNull(parameterIndex, sqlType);    }    finally {      profiler.finish();    }  }  public void setBoolean(int parameterIndex, boolean x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setBoolean(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setByte(int parameterIndex, byte x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setByte(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setShort(int parameterIndex, short x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setShort(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setInt(int parameterIndex, int x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setInt(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setLong(int parameterIndex, long x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setLong(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setFloat(int parameterIndex, float x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setFloat(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setDouble(int parameterIndex, double x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setDouble(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setBigDecimal(int parameterIndex, BigDecimal x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setBigDecimal(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setString(int parameterIndex, String x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setString(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setBytes(int parameterIndex, byte[] x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setBytes(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setDate(int parameterIndex, Date x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setDate(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setTime(int parameterIndex, Time x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setTime(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setTimestamp(int parameterIndex, Timestamp x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setTimestamp(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public void setAsciiStream(int parameterIndex, InputStream x, int length)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setAsciiStream(parameterIndex, x, length);    }    finally {      profiler.finish();    }  }  public void setUnicodeStream(int parameterIndex, InputStream x, int length)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setUnicodeStream(parameterIndex, x, length);    }    finally {      profiler.finish();    }  }  public void setBinaryStream(int parameterIndex, InputStream x, int length)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setBinaryStream(parameterIndex, x, length);    }    finally {      profiler.finish();    }  }  public void clearParameters()    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.clearParameters();    }    finally {      profiler.finish();    }  }  public void setObject(int parameterIndex,                        Object x,                        int targetSqlType,                        int scale)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setObject(parameterIndex, x, targetSqlType, scale);    }    finally {      profiler.finish();    }  }  public void setObject(int parameterIndex, Object x, int targetSqlType)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setObject(parameterIndex, x, targetSqlType);    }    finally {      profiler.finish();    }  }  public void setObject(int parameterIndex, Object x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setObject(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public boolean execute()    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      return _preparedStatement.execute();    }    finally {      profiler.finish();    }  }  public void addBatch()    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.addBatch();    }    finally {      profiler.finish();    }  }  public void setCharacterStream(int parameterIndex, Reader reader, int length)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setCharacterStream(parameterIndex, reader, length);    }    finally {      profiler.finish();    }  }  public void setRef(int i, Ref x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setRef(i, x);    }    finally {      profiler.finish();    }  }  public void setBlob(int i, Blob x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setBlob(i, x);    }    finally {      profiler.finish();    }  }  public void setClob(int i, Clob x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setClob(i, x);    }    finally {      profiler.finish();    }  }  public void setArray(int i, Array x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setArray(i, x);    }    finally {      profiler.finish();    }  }  public ResultSetMetaData getMetaData()    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      return _preparedStatement.getMetaData();    }    finally {      profiler.finish();    }  }  public void setDate(int parameterIndex, Date x, Calendar cal)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setDate(parameterIndex, x, cal);    }    finally {      profiler.finish();    }  }  public void setTime(int parameterIndex, Time x, Calendar cal)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setTime(parameterIndex, x, cal);    }    finally {      profiler.finish();    }  }  public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setTimestamp(parameterIndex, x, cal);    }    finally {      profiler.finish();    }  }  public void setNull(int paramIndex, int sqlType, String typeName)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setNull(paramIndex, sqlType, typeName);    }    finally {      profiler.finish();    }  }  public void setURL(int parameterIndex, URL x)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      _preparedStatement.setURL(parameterIndex, x);    }    finally {      profiler.finish();    }  }  public ParameterMetaData getParameterMetaData()    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      return _preparedStatement.getParameterMetaData();    }    finally {      profiler.finish();    }  }  public ResultSet executeQuery(String sql)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      return _preparedStatement.executeQuery(sql);    }    finally {      profiler.finish();    }  }  public int executeUpdate(String sql)    throws SQLException  {    Profiler profiler = _profilerPoint.start();    try {      return _preparedStatement.executeUpdate(sql);    }    finally {      profiler.finish();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?