1 21 22 package uk.org.primrose.pool.core; 23 import java.sql.*; 24 25 30 public class PoolStatement implements Statement { 31 Statement s = null; 32 PoolSqlMonitor poolSqlMonitor = null; 33 34 public PoolStatement(Statement s, PoolSqlMonitor poolSqlMonitor) { 35 this.poolSqlMonitor = poolSqlMonitor; 36 poolSqlMonitor.setStatementClosed(false); 37 poolSqlMonitor.setStatement(this); 38 this.s = s; 39 } 40 41 public PoolStatement(){} 42 43 public void setPoolSqlMonitor(PoolSqlMonitor poolSqlMonitor) { 44 this.poolSqlMonitor = poolSqlMonitor; 45 } 46 47 public PoolSqlMonitor getPoolSqlMonitor() { 48 return poolSqlMonitor; 49 } 50 51 public void close() throws SQLException { 52 if (poolSqlMonitor.isStatementClosed() == false) { 53 poolSqlMonitor.setStatementClosed(true); 54 s.close(); 55 } 56 } 57 58 public ResultSet executeQuery(String sql) throws SQLException { 59 PoolResultSet prs = new PoolResultSet(s.executeQuery(sql), this.getPoolSqlMonitor()); 60 this.getPoolSqlMonitor().setSql(sql); 61 return prs; 62 } 63 64 public int executeUpdate(String sql) throws SQLException { 65 this.getPoolSqlMonitor().setSql(sql); 66 return s.executeUpdate(sql); 67 } 68 69 public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { 70 this.getPoolSqlMonitor().setSql(sql); 71 return s.executeUpdate(sql, autoGeneratedKeys); 72 } 73 74 public int executeUpdate(String sql, int columnIndexes[]) throws SQLException { 75 this.getPoolSqlMonitor().setSql(sql); 76 return s.executeUpdate(sql, columnIndexes); 77 } 78 79 public int executeUpdate(String sql, String columnNames[]) throws SQLException { 80 this.getPoolSqlMonitor().setSql(sql); 81 return s.executeUpdate(sql, columnNames); 82 } 83 84 public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { 85 this.getPoolSqlMonitor().setSql(sql); 86 return s.execute(sql, autoGeneratedKeys); 87 } 88 89 public boolean execute(String sql, int columnIndexes[]) throws SQLException { 90 this.getPoolSqlMonitor().setSql(sql); 91 return s.execute(sql, columnIndexes); 92 } 93 94 public boolean execute(String sql, String columnNames[]) throws SQLException { 95 this.getPoolSqlMonitor().setSql(sql); 96 return s.execute(sql, columnNames); 97 } 98 99 public int[] executeBatch() throws SQLException { 100 return s.executeBatch(); 101 } 102 103 public int getMaxFieldSize() throws SQLException { 104 return s.getMaxFieldSize(); 105 } 106 107 public void setMaxFieldSize(int max) throws SQLException { 108 s.setMaxFieldSize(max); 109 } 110 111 public int getMaxRows() throws SQLException { 112 return s.getMaxRows(); 113 } 114 115 public void setMaxRows(int max) throws SQLException { 116 s.setMaxRows(max); 117 } 118 119 public void setEscapeProcessing(boolean enable) throws SQLException { 120 s.setEscapeProcessing(enable); 121 } 122 123 public int getQueryTimeout() throws SQLException { 124 return s.getQueryTimeout(); 125 } 126 127 public void setQueryTimeout(int seconds) throws SQLException { 128 s.setQueryTimeout(seconds); 129 } 130 131 public void cancel() throws SQLException { 132 s.cancel(); 133 } 134 135 public SQLWarning getWarnings() throws SQLException { 136 return s.getWarnings(); 137 } 138 139 public void clearWarnings() throws SQLException { 140 s.clearWarnings(); 141 } 142 143 public void setCursorName(String name) throws SQLException { 144 s.setCursorName(name); 145 } 146 147 public boolean execute(String sql) throws SQLException { 148 this.getPoolSqlMonitor().setSql(sql); 149 return s.execute(sql); 150 } 151 152 public ResultSet getResultSet() throws SQLException { 153 PoolResultSet prs = new PoolResultSet(s.getResultSet(), this.getPoolSqlMonitor()); 154 return prs; 155 } 156 157 public int getUpdateCount() throws SQLException { 158 return s.getUpdateCount(); 159 } 160 161 public boolean getMoreResults() throws SQLException { 162 return s.getMoreResults(); 163 } 164 165 public void setFetchDirection(int direction) throws SQLException { 166 s.setFetchDirection(direction); 167 } 168 169 public int getFetchDirection() throws SQLException { 170 return s.getFetchDirection(); 171 } 172 173 public void setFetchSize(int rows) throws SQLException { 174 s.setFetchSize(rows); 175 } 176 177 public int getFetchSize() throws SQLException { 178 return s.getFetchSize(); 179 } 180 181 public int getResultSetConcurrency() throws SQLException { 182 return s.getResultSetConcurrency(); 183 } 184 185 public int getResultSetType() throws SQLException { 186 return s.getResultSetType(); 187 } 188 189 public void addBatch(String sql) throws SQLException { 190 s.addBatch(sql); 191 } 192 193 public void clearBatch() throws SQLException { 194 s.clearBatch(); 195 } 196 197 public Connection getConnection() throws SQLException { 198 return s.getConnection(); 199 } 200 201 public boolean getMoreResults(int current) throws SQLException { 202 return s.getMoreResults(current); 203 } 204 205 public ResultSet getGeneratedKeys() throws SQLException { 206 PoolResultSet prs = new PoolResultSet(s.getGeneratedKeys(), this.getPoolSqlMonitor()); 207 return prs; 208 } 209 210 public int getResultSetHoldability() throws SQLException { 211 return s.getResultSetHoldability(); 212 } 213 214 } | Popular Tags |