Coverage report

  %line %branch
net.sf.infrared.aspects.jdbc.p6spy.InfraREDP6PreparedStatement
0% 
0% 

 1  
 /* 
 2  
  * Copyright 2005 Tavant Technologies and Contributors
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License")
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  * 
 16  
  *
 17  
  *
 18  
  * Original Author:  kamal.govindraj (Tavant Technologies)
 19  
  * Contributor(s):   prashant.nair, binil.thomas;
 20  
  *
 21  
  */
 22  
 package net.sf.infrared.aspects.jdbc.p6spy;
 23  
 
 24  
 import java.io.InputStream;
 25  
 import java.io.Reader;
 26  
 import java.math.BigDecimal;
 27  
 import java.net.URL;
 28  
 import java.sql.Array;
 29  
 import java.sql.Blob;
 30  
 import java.sql.Clob;
 31  
 import java.sql.Date;
 32  
 import java.sql.ParameterMetaData;
 33  
 import java.sql.PreparedStatement;
 34  
 import java.sql.Ref;
 35  
 import java.sql.ResultSet;
 36  
 import java.sql.ResultSetMetaData;
 37  
 import java.sql.SQLException;
 38  
 import java.sql.Time;
 39  
 import java.sql.Timestamp;
 40  
 import java.util.Calendar;
 41  
 
 42  
 import net.sf.infrared.agent.MonitorFactory;
 43  
 import net.sf.infrared.agent.StatisticsCollector;
 44  
 import net.sf.infrared.base.model.ExecutionContext;
 45  
 import net.sf.infrared.base.model.ExecutionTimer;
 46  
 
 47  
 import com.p6spy.engine.spy.P6Connection;
 48  
 import com.p6spy.engine.spy.P6PreparedStatement;
 49  
 import com.p6spy.engine.spy.P6Statement;
 50  
 
 51  
 /**
 52  
  * This class is used by the P6Spy driver as a wrapper for PreparedStatement Not
 53  
  * inheriting from P6PreparedStatement as its implementation add overhead by
 54  
  * collecting bind values etc.
 55  
  * 
 56  
  * @author kamal.govindraj
 57  
  * @author prashant.nair
 58  
  * @author binil.thomas
 59  
  */
 60  
 public class InfraREDP6PreparedStatement extends InfraREDP6Statement implements PreparedStatement {
 61  
     private PreparedStatement passThru;
 62  
 
 63  
     private String preparedQuery;
 64  
 
 65  
     private ExecutionContext executeCtx;
 66  
 
 67  
     public InfraREDP6PreparedStatement(InfraREDP6Factory infraP6Factory, PreparedStatement real,
 68  
             P6Connection conn, String sql) {
 69  
 
 70  0
         super(infraP6Factory, real, conn);
 71  0
         this.passThru = real;
 72  0
         this.factory = infraP6Factory;
 73  0
         this.preparedQuery = sql;
 74  0
         this.conn = conn;
 75  0
         executeCtx = infraP6Factory.getExecuteContext(sql);
 76  0
     }
 77  
 
 78  
     public boolean execute() throws SQLException {
 79  0
         if (factory.isJDBCMonitoringEnabled()) {
 80  0
             ExecutionTimer timer = new ExecutionTimer(executeCtx);
 81  0
             StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 82  
             try {
 83  0
                 return passThru.execute();
 84  
             } finally {
 85  0
                 MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 86  
             }       
 87  
         } else {
 88  0
             return passThru.execute();
 89  
         }
 90  
     }
 91  
 
 92  
     public void addBatch() throws SQLException {
 93  0
         passThru.addBatch();
 94  0
     }
 95  
 
 96  
     public void setCharacterStream(int parameterIndex, Reader reader, class="keyword">int length)
 97  
             throws SQLException {
 98  0
         passThru.setCharacterStream(parameterIndex, reader, length);
 99  0
     }
 100  
 
 101  
     public void setRef(int i, Ref x) throws SQLException {
 102  0
         passThru.setRef(i, x);
 103  0
     }
 104  
 
 105  
     public void setBlob(int i, Blob x) throws SQLException {
 106  0
         passThru.setBlob(i, x);
 107  0
     }
 108  
 
 109  
     public void setClob(int i, Clob x) throws SQLException {
 110  0
         passThru.setClob(i, x);
 111  0
     }
 112  
 
 113  
     public void setArray(int i, Array x) throws SQLException {
 114  0
         passThru.setArray(i, x);
 115  0
     }
 116  
 
 117  
     public ResultSetMetaData getMetaData() throws SQLException {
 118  0
         return factory.getResultSetMetaData(passThru.getMetaData());
 119  
     }
 120  
 
 121  
     public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException {
 122  0
         passThru.setDate(parameterIndex, x, cal);
 123  0
     }
 124  
 
 125  
     public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException {
 126  0
         passThru.setTime(parameterIndex, x, cal);
 127  0
     }
 128  
 
 129  
     public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException {
 130  0
         passThru.setTimestamp(parameterIndex, x, cal);
 131  0
     }
 132  
 
 133  
     public void setNull(int paramIndex, class="keyword">int sqlType, String typeName) throws SQLException {
 134  0
         passThru.setNull(paramIndex, sqlType, typeName);
 135  0
     }
 136  
 
 137  
     public void setURL(int parameterIndex, URL x) throws SQLException {
 138  0
         passThru.setURL(parameterIndex, x);
 139  0
     }
 140  
 
 141  
     public ParameterMetaData getParameterMetaData() throws SQLException {
 142  0
         return passThru.getParameterMetaData();
 143  
     }
 144  
 
 145  
     public ResultSet executeQuery() throws SQLException {
 146  0
         ResultSet resultSet = null;
 147  0
         if (factory.isJDBCMonitoringEnabled()) {
 148  0
             ExecutionTimer timer = new ExecutionTimer(executeCtx);
 149  0
             StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 150  
             try {
 151  0
                 resultSet = passThru.executeQuery();
 152  
             } finally {
 153  0
                 MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 154  0
             }
 155  
         } else {
 156  0
             resultSet = passThru.executeQuery();
 157  
         }
 158  0
         return factory.getResultSet(resultSet, getP6Statement(), preparedQuery, query);
 159  
     }
 160  
 
 161  
     public int executeUpdate() throws SQLException {
 162  
         int returnValue;
 163  
         
 164  0
         if (factory.isJDBCMonitoringEnabled()) {
 165  0
             ExecutionTimer timer = new ExecutionTimer(executeCtx);
 166  0
             StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 167  
             try {
 168  0
                 returnValue = passThru.executeUpdate();
 169  
             } finally {
 170  0
                 MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 171  0
             }
 172  
         } else {
 173  0
             returnValue = passThru.executeUpdate();
 174  
         }
 175  
 
 176  0
         return class="keyword">returnValue;
 177  
     }
 178  
 
 179  
     public void setNull(int parameterIndex, class="keyword">int sqlType) throws SQLException {
 180  0
         passThru.setNull(parameterIndex, sqlType);
 181  0
     }
 182  
 
 183  
     public void setBoolean(int parameterIndex, boolean x) throws SQLException {
 184  0
         passThru.setBoolean(parameterIndex, x);
 185  0
     }
 186  
 
 187  
     public void setByte(int parameterIndex, byte x) throws SQLException {
 188  0
         passThru.setByte(parameterIndex, x);
 189  0
     }
 190  
 
 191  
     public void setShort(int parameterIndex, short x) throws SQLException {
 192  0
         passThru.setShort(parameterIndex, x);
 193  0
     }
 194  
 
 195  
     public void setInt(int parameterIndex, class="keyword">int x) throws SQLException {
 196  0
         passThru.setInt(parameterIndex, x);
 197  0
     }
 198  
 
 199  
     public void setLong(int parameterIndex, long x) throws SQLException {
 200  0
         passThru.setLong(parameterIndex, x);
 201  0
     }
 202  
 
 203  
     public void setFloat(int parameterIndex, float x) throws SQLException {
 204  0
         passThru.setFloat(parameterIndex, x);
 205  0
     }
 206  
 
 207  
     public void setDouble(int parameterIndex, double x) throws SQLException {
 208  0
         passThru.setDouble(parameterIndex, x);
 209  0
     }
 210  
 
 211  
     public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
 212  0
         passThru.setBigDecimal(parameterIndex, x);
 213  0
     }
 214  
 
 215  
     public void setString(int parameterIndex, String x) throws SQLException {
 216  0
         passThru.setString(parameterIndex, x);
 217  0
     }
 218  
 
 219  
     public void setBytes(int parameterIndex, byte x[]) throws SQLException {
 220  0
         passThru.setBytes(parameterIndex, x);
 221  0
     }
 222  
 
 223  
     public void setDate(int parameterIndex, Date x) throws SQLException {
 224  0
         passThru.setDate(parameterIndex, x);
 225  0
     }
 226  
 
 227  
     public void setTime(int parameterIndex, Time x) throws SQLException {
 228  0
         passThru.setTime(parameterIndex, x);
 229  0
     }
 230  
 
 231  
     public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
 232  0
         passThru.setTimestamp(parameterIndex, x);
 233  0
     }
 234  
 
 235  
     public void setAsciiStream(int parameterIndex, InputStream x, class="keyword">int length) throws SQLException {
 236  0
         passThru.setAsciiStream(parameterIndex, x, length);
 237  0
     }
 238  
 
 239  
     public void setUnicodeStream(int parameterIndex, InputStream x, class="keyword">int length) throws SQLException {
 240  0
         passThru.setUnicodeStream(parameterIndex, x, length);
 241  0
     }
 242  
 
 243  
     public void setBinaryStream(int parameterIndex, InputStream x, class="keyword">int length) throws SQLException {
 244  0
         passThru.setBinaryStream(parameterIndex, x, length);
 245  0
     }
 246  
 
 247  
     public void clearParameters() throws SQLException {
 248  0
         passThru.clearParameters();
 249  0
     }
 250  
 
 251  
     public void setObject(int parameterIndex, Object x, class="keyword">int targetSqlType, class="keyword">int scale)
 252  
             throws SQLException {
 253  0
         passThru.setObject(parameterIndex, x, targetSqlType, scale);
 254  0
     }
 255  
 
 256  
     public void setObject(int parameterIndex, Object x, class="keyword">int targetSqlType) throws SQLException {
 257  0
         passThru.setObject(parameterIndex, x, targetSqlType);
 258  0
     }
 259  
 
 260  
     public void setObject(int parameterIndex, Object x) throws SQLException {
 261  0
         passThru.setObject(parameterIndex, x);
 262  0
     }
 263  
 
 264  
     protected P6Statement getP6Statement() {
 265  0
         if (p6Statement == null) {
 266  0
             p6Statement = new P6PreparedStatement(factory, this, conn, preparedQuery);
 267  
         }
 268  0
         return p6Statement;
 269  
     }
 270  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.