|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
StatementMeasure.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Joey and its relative products are published under the terms
|
|
3 |
* of the Apache Software License.
|
|
4 |
*/
|
|
5 |
package org.asyrinx.brownie.jdbc.measure;
|
|
6 |
|
|
7 |
import java.sql.Connection;
|
|
8 |
import java.sql.ResultSet;
|
|
9 |
import java.sql.SQLException;
|
|
10 |
import java.sql.SQLWarning;
|
|
11 |
import java.sql.Statement;
|
|
12 |
|
|
13 |
import org.asyrinx.brownie.core.log.MeasureLog;
|
|
14 |
import org.asyrinx.brownie.core.log.MeasureLogImpl;
|
|
15 |
import org.asyrinx.brownie.core.util.Wrapper;
|
|
16 |
|
|
17 |
/**
|
|
18 |
* @author Akima
|
|
19 |
*/
|
|
20 |
public class StatementMeasure extends Wrapper implements Statement { |
|
21 |
|
|
22 |
/**
|
|
23 |
* Constructor for StatementMeasure.
|
|
24 |
*/
|
|
25 | 0 |
public StatementMeasure(Statement source, MeasureLog measureLog) {
|
26 | 0 |
super(source);
|
27 | 0 |
this.source = source;
|
28 | 0 |
if (measureLog == null) |
29 | 0 |
measureLog = new MeasureLogImpl("sql"); |
30 | 0 |
this.measureLog = measureLog;
|
31 |
} |
|
32 |
|
|
33 |
/**
|
|
34 |
* Constructor for StatementMeasure.
|
|
35 |
*/
|
|
36 | 0 |
public StatementMeasure(Statement source) {
|
37 | 0 |
this(source, null); |
38 |
} |
|
39 |
|
|
40 |
protected final MeasureLog measureLog;
|
|
41 |
|
|
42 |
private final Statement source;
|
|
43 |
|
|
44 |
protected static final String PREFIX = "[measure]"; |
|
45 |
|
|
46 | 0 |
public static String format(String name, long t) { |
47 | 0 |
return PREFIX + " " + name + " -- " + String.valueOf(t); |
48 |
} |
|
49 |
|
|
50 |
/**
|
|
51 |
* @see java.sql.Statement#execute(String)
|
|
52 |
*/
|
|
53 | 0 |
public boolean execute(String sql) throws SQLException { |
54 | 0 |
measureLog.reset(); |
55 | 0 |
final boolean result = source.execute(sql);
|
56 | 0 |
measureLog.done(sql); |
57 | 0 |
return result;
|
58 |
} |
|
59 |
|
|
60 |
/**
|
|
61 |
* @see java.sql.Statement#executeQuery(String)
|
|
62 |
*/
|
|
63 | 0 |
public ResultSet executeQuery(String sql) throws SQLException { |
64 | 0 |
measureLog.reset(); |
65 | 0 |
final ResultSet result = source.executeQuery(sql); |
66 | 0 |
measureLog.done(sql); |
67 | 0 |
return result;
|
68 |
} |
|
69 |
|
|
70 |
/**
|
|
71 |
* @see java.sql.Statement#executeUpdate(String)
|
|
72 |
*/
|
|
73 | 0 |
public int executeUpdate(String sql) throws SQLException { |
74 | 0 |
measureLog.reset(); |
75 | 0 |
final int result = source.executeUpdate(sql);
|
76 | 0 |
measureLog.done(sql); |
77 | 0 |
return result;
|
78 |
} |
|
79 |
|
|
80 |
/**
|
|
81 |
* @see java.sql.Statement#addBatch(String)
|
|
82 |
*/
|
|
83 | 0 |
public void addBatch(String sql) throws SQLException { |
84 | 0 |
source.addBatch(sql); |
85 |
} |
|
86 |
|
|
87 |
/**
|
|
88 |
* @see java.sql.Statement#clearBatch()
|
|
89 |
*/
|
|
90 | 0 |
public void clearBatch() throws SQLException { |
91 | 0 |
source.clearBatch(); |
92 |
} |
|
93 |
|
|
94 |
/**
|
|
95 |
* @see java.sql.Statement#executeBatch()
|
|
96 |
*/
|
|
97 | 0 |
public int[] executeBatch() throws SQLException { |
98 | 0 |
measureLog.reset(); |
99 | 0 |
final int[] result = source.executeBatch();
|
100 | 0 |
measureLog.done("batch");
|
101 | 0 |
return result;
|
102 |
} |
|
103 |
|
|
104 |
/**
|
|
105 |
* @see java.sql.Statement#close()
|
|
106 |
*/
|
|
107 | 0 |
public void close() throws SQLException { |
108 | 0 |
source.close(); |
109 |
} |
|
110 |
|
|
111 |
/**
|
|
112 |
* @see java.sql.Statement#getMaxFieldSize()
|
|
113 |
*/
|
|
114 | 0 |
public int getMaxFieldSize() throws SQLException { |
115 | 0 |
return source.getMaxFieldSize();
|
116 |
} |
|
117 |
|
|
118 |
/**
|
|
119 |
* @see java.sql.Statement#setMaxFieldSize(int)
|
|
120 |
*/
|
|
121 | 0 |
public void setMaxFieldSize(int max) throws SQLException { |
122 | 0 |
source.setMaxFieldSize(max); |
123 |
} |
|
124 |
|
|
125 |
/**
|
|
126 |
* @see java.sql.Statement#getMaxRows()
|
|
127 |
*/
|
|
128 | 0 |
public int getMaxRows() throws SQLException { |
129 | 0 |
return source.getMaxRows();
|
130 |
} |
|
131 |
|
|
132 |
/**
|
|
133 |
* @see java.sql.Statement#setMaxRows(int)
|
|
134 |
*/
|
|
135 | 0 |
public void setMaxRows(int max) throws SQLException { |
136 | 0 |
source.setMaxRows(max); |
137 |
} |
|
138 |
|
|
139 |
/**
|
|
140 |
* @see java.sql.Statement#setEscapeProcessing(boolean)
|
|
141 |
*/
|
|
142 | 0 |
public void setEscapeProcessing(boolean enable) throws SQLException { |
143 | 0 |
source.setEscapeProcessing(enable); |
144 |
} |
|
145 |
|
|
146 |
/**
|
|
147 |
* @see java.sql.Statement#getQueryTimeout()
|
|
148 |
*/
|
|
149 | 0 |
public int getQueryTimeout() throws SQLException { |
150 | 0 |
return source.getQueryTimeout();
|
151 |
} |
|
152 |
|
|
153 |
/**
|
|
154 |
* @see java.sql.Statement#setQueryTimeout(int)
|
|
155 |
*/
|
|
156 | 0 |
public void setQueryTimeout(int seconds) throws SQLException { |
157 | 0 |
source.setQueryTimeout(seconds); |
158 |
} |
|
159 |
|
|
160 |
/**
|
|
161 |
* @see java.sql.Statement#cancel()
|
|
162 |
*/
|
|
163 | 0 |
public void cancel() throws SQLException { |
164 | 0 |
source.cancel(); |
165 |
} |
|
166 |
|
|
167 |
/**
|
|
168 |
* @see java.sql.Statement#getWarnings()
|
|
169 |
*/
|
|
170 | 0 |
public SQLWarning getWarnings() throws SQLException { |
171 | 0 |
return source.getWarnings();
|
172 |
} |
|
173 |
|
|
174 |
/**
|
|
175 |
* @see java.sql.Statement#clearWarnings()
|
|
176 |
*/
|
|
177 | 0 |
public void clearWarnings() throws SQLException { |
178 | 0 |
source.clearWarnings(); |
179 |
} |
|
180 |
|
|
181 |
/**
|
|
182 |
* @see java.sql.Statement#setCursorName(String)
|
|
183 |
*/
|
|
184 | 0 |
public void setCursorName(String name) throws SQLException { |
185 | 0 |
source.setCursorName(name); |
186 |
} |
|
187 |
|
|
188 |
/**
|
|
189 |
* @see java.sql.Statement#getResultSet()
|
|
190 |
*/
|
|
191 | 0 |
public ResultSet getResultSet() throws SQLException { |
192 | 0 |
return source.getResultSet();
|
193 |
} |
|
194 |
|
|
195 |
/**
|
|
196 |
* @see java.sql.Statement#getUpdateCount()
|
|
197 |
*/
|
|
198 | 0 |
public int getUpdateCount() throws SQLException { |
199 | 0 |
return source.getUpdateCount();
|
200 |
} |
|
201 |
|
|
202 |
/**
|
|
203 |
* @see java.sql.Statement#getMoreResults()
|
|
204 |
*/
|
|
205 | 0 |
public boolean getMoreResults() throws SQLException { |
206 | 0 |
return source.getMoreResults();
|
207 |
} |
|
208 |
|
|
209 |
/**
|
|
210 |
* @see java.sql.Statement#setFetchDirection(int)
|
|
211 |
*/
|
|
212 | 0 |
public void setFetchDirection(int direction) throws SQLException { |
213 | 0 |
source.setFetchDirection(direction); |
214 |
} |
|
215 |
|
|
216 |
/**
|
|
217 |
* @see java.sql.Statement#getFetchDirection()
|
|
218 |
*/
|
|
219 | 0 |
public int getFetchDirection() throws SQLException { |
220 | 0 |
return source.getFetchDirection();
|
221 |
} |
|
222 |
|
|
223 |
/**
|
|
224 |
* @see java.sql.Statement#setFetchSize(int)
|
|
225 |
*/
|
|
226 | 0 |
public void setFetchSize(int rows) throws SQLException { |
227 | 0 |
source.setFetchSize(rows); |
228 |
} |
|
229 |
|
|
230 |
/**
|
|
231 |
* @see java.sql.Statement#getFetchSize()
|
|
232 |
*/
|
|
233 | 0 |
public int getFetchSize() throws SQLException { |
234 | 0 |
return source.getFetchSize();
|
235 |
} |
|
236 |
|
|
237 |
/**
|
|
238 |
* @see java.sql.Statement#getResultSetConcurrency()
|
|
239 |
*/
|
|
240 | 0 |
public int getResultSetConcurrency() throws SQLException { |
241 | 0 |
return source.getResultSetConcurrency();
|
242 |
} |
|
243 |
|
|
244 |
/**
|
|
245 |
* @see java.sql.Statement#getResultSetType()
|
|
246 |
*/
|
|
247 | 0 |
public int getResultSetType() throws SQLException { |
248 | 0 |
return source.getResultSetType();
|
249 |
} |
|
250 |
|
|
251 |
/**
|
|
252 |
* @see java.sql.Statement#getConnection()
|
|
253 |
*/
|
|
254 | 0 |
public Connection getConnection() throws SQLException { |
255 | 0 |
return source.getConnection();
|
256 |
} |
|
257 |
|
|
258 |
/**
|
|
259 |
* @param sql
|
|
260 |
* @param autoGeneratedKeys
|
|
261 |
* @return @throws
|
|
262 |
* java.sql.SQLException
|
|
263 |
*/
|
|
264 | 0 |
public boolean execute(String sql, int autoGeneratedKeys) |
265 |
throws SQLException {
|
|
266 | 0 |
return source.execute(sql, autoGeneratedKeys);
|
267 |
} |
|
268 |
|
|
269 |
/**
|
|
270 |
* @param sql
|
|
271 |
* @param columnIndexes
|
|
272 |
* @return @throws
|
|
273 |
* java.sql.SQLException
|
|
274 |
*/
|
|
275 | 0 |
public boolean execute(String sql, int[] columnIndexes) throws SQLException { |
276 | 0 |
return source.execute(sql, columnIndexes);
|
277 |
} |
|
278 |
|
|
279 |
/**
|
|
280 |
* @param sql
|
|
281 |
* @param columnNames
|
|
282 |
* @return @throws
|
|
283 |
* java.sql.SQLException
|
|
284 |
*/
|
|
285 | 0 |
public boolean execute(String sql, String[] columnNames) |
286 |
throws SQLException {
|
|
287 | 0 |
return source.execute(sql, columnNames);
|
288 |
} |
|
289 |
|
|
290 |
/**
|
|
291 |
* @param sql
|
|
292 |
* @param autoGeneratedKeys
|
|
293 |
* @return @throws
|
|
294 |
* java.sql.SQLException
|
|
295 |
*/
|
|
296 | 0 |
public int executeUpdate(String sql, int autoGeneratedKeys) |
297 |
throws SQLException {
|
|
298 | 0 |
return source.executeUpdate(sql, autoGeneratedKeys);
|
299 |
} |
|
300 |
|
|
301 |
/**
|
|
302 |
* @param sql
|
|
303 |
* @param columnIndexes
|
|
304 |
* @return @throws
|
|
305 |
* java.sql.SQLException
|
|
306 |
*/
|
|
307 | 0 |
public int executeUpdate(String sql, int[] columnIndexes) |
308 |
throws SQLException {
|
|
309 | 0 |
return source.executeUpdate(sql, columnIndexes);
|
310 |
} |
|
311 |
|
|
312 |
/**
|
|
313 |
* @param sql
|
|
314 |
* @param columnNames
|
|
315 |
* @return @throws
|
|
316 |
* java.sql.SQLException
|
|
317 |
*/
|
|
318 | 0 |
public int executeUpdate(String sql, String[] columnNames) |
319 |
throws SQLException {
|
|
320 | 0 |
return source.executeUpdate(sql, columnNames);
|
321 |
} |
|
322 |
|
|
323 |
/**
|
|
324 |
* @return @throws
|
|
325 |
* java.sql.SQLException
|
|
326 |
*/
|
|
327 | 0 |
public ResultSet getGeneratedKeys() throws SQLException { |
328 | 0 |
return source.getGeneratedKeys();
|
329 |
} |
|
330 |
|
|
331 |
/**
|
|
332 |
* @param current
|
|
333 |
* @return @throws
|
|
334 |
* java.sql.SQLException
|
|
335 |
*/
|
|
336 | 0 |
public boolean getMoreResults(int current) throws SQLException { |
337 | 0 |
return source.getMoreResults(current);
|
338 |
} |
|
339 |
|
|
340 |
/**
|
|
341 |
* @return @throws
|
|
342 |
* java.sql.SQLException
|
|
343 |
*/
|
|
344 | 0 |
public int getResultSetHoldability() throws SQLException { |
345 | 0 |
return source.getResultSetHoldability();
|
346 |
} |
|
347 |
|
|
348 |
} |
|