1 |
|
package net.sf.infrared.aspects.jdbc.p6spy; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
import java.sql.PreparedStatement; |
26 |
|
import java.sql.ResultSet; |
27 |
|
import java.sql.SQLException; |
28 |
|
|
29 |
|
import net.sf.infrared.agent.MonitorFactory; |
30 |
|
import net.sf.infrared.aspects.jdbc.SqlExecuteContext; |
31 |
|
import net.sf.infrared.base.model.ExecutionTimer; |
32 |
|
import net.sf.infrared.base.model.ExecutionContext; |
33 |
|
import net.sf.infrared.agent.StatisticsCollector; |
34 |
|
|
35 |
|
import com.p6spy.engine.spy.P6Connection; |
36 |
|
import com.p6spy.engine.spy.P6PreparedStatement; |
37 |
|
import com.p6spy.engine.spy.P6Statement; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
public class InfraREDP6PreparedStatementWithVariables extends P6PreparedStatement { |
45 |
|
protected InfraREDP6Factory factory; |
46 |
|
|
47 |
|
private ExecutionContext executeCtx; |
48 |
|
|
49 |
|
public InfraREDP6PreparedStatementWithVariables(InfraREDP6Factory infraP6Factory, |
50 |
|
PreparedStatement real, P6Connection conn, String sql) { |
51 |
0 |
super(infraP6Factory, real, conn,sql); |
52 |
0 |
this.factory = infraP6Factory; |
53 |
0 |
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
public boolean execute() throws SQLException { |
70 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(getQueryFromPreparedStatement()); |
71 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
72 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
73 |
|
|
74 |
|
try { |
75 |
0 |
return prepStmtPassthru.execute(); |
76 |
|
} finally { |
77 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
78 |
|
} |
79 |
|
} |
80 |
|
|
81 |
|
public ResultSet executeQuery() throws SQLException { |
82 |
0 |
ResultSet resultSet = null; |
83 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(getQueryFromPreparedStatement()); |
84 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
85 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
86 |
|
try { |
87 |
0 |
resultSet = prepStmtPassthru.executeQuery(); |
88 |
|
} finally { |
89 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
90 |
0 |
} |
91 |
0 |
return factory.getResultSet(resultSet, getP6Statement(), preparedQuery, getQueryFromPreparedStatement()); |
92 |
|
} |
93 |
|
|
94 |
|
public int executeUpdate() throws SQLException { |
95 |
|
int returnValue; |
96 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(getQueryFromPreparedStatement()); |
97 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
98 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
99 |
|
try { |
100 |
0 |
returnValue = prepStmtPassthru.executeUpdate(); |
101 |
|
} finally { |
102 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
103 |
0 |
} |
104 |
0 |
return class="keyword">returnValue; |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
public boolean execute(String p0) throws java.sql.SQLException { |
117 |
0 |
statementQuery = p0; |
118 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
119 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
120 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
121 |
|
try { |
122 |
0 |
return passthru.execute(p0); |
123 |
|
} finally { |
124 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
125 |
|
} |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
public boolean execute(String p0, int p1) throws java.sql.SQLException { |
130 |
0 |
statementQuery = p0; |
131 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
132 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
133 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
134 |
|
try { |
135 |
0 |
return passthru.execute(p0, p1); |
136 |
|
} finally { |
137 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
138 |
|
} |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
public boolean execute(String p0, int p1[]) throws java.sql.SQLException { |
143 |
0 |
statementQuery = p0; |
144 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
145 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
146 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
147 |
|
try { |
148 |
0 |
return passthru.execute(p0, p1); |
149 |
|
} finally { |
150 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
151 |
|
} |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
public boolean execute(String p0, String p1[]) throws java.sql.SQLException { |
156 |
0 |
statementQuery = p0; |
157 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
158 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
159 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
160 |
|
try { |
161 |
0 |
return passthru.execute(p0, p1); |
162 |
|
} |
163 |
|
finally { |
164 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
165 |
|
} |
166 |
|
} |
167 |
|
|
168 |
|
public ResultSet executeQuery(String p0) throws java.sql.SQLException { |
169 |
|
ResultSet resultSet; |
170 |
0 |
statementQuery = p0; |
171 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
172 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
173 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
174 |
|
try { |
175 |
0 |
resultSet = passthru.executeQuery(p0); |
176 |
|
} finally { |
177 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
178 |
0 |
} |
179 |
0 |
return factory.getResultSet(resultSet, getP6Statement(), p0, p0); |
180 |
|
} |
181 |
|
|
182 |
|
public int executeUpdate(String p0) throws java.sql.SQLException { |
183 |
0 |
statementQuery = p0; |
184 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
185 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
186 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
187 |
|
try { |
188 |
0 |
return passthru.executeUpdate(p0); |
189 |
|
} finally { |
190 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
191 |
|
} |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
public int executeUpdate(String p0, class="keyword">int p1) throws java.sql.SQLException { |
196 |
0 |
statementQuery = p0; |
197 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
198 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
199 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
200 |
|
try { |
201 |
0 |
return passthru.executeUpdate(p0, p1); |
202 |
|
} finally { |
203 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
204 |
|
} |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
public int executeUpdate(String p0, class="keyword">int p1[]) throws java.sql.SQLException { |
209 |
0 |
statementQuery = p0; |
210 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
211 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
212 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
213 |
|
try { |
214 |
0 |
return(passthru.executeUpdate(p0, p1)); |
215 |
|
} |
216 |
|
finally { |
217 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
218 |
|
} |
219 |
|
} |
220 |
|
|
221 |
|
|
222 |
|
public int executeUpdate(String p0, String p1[]) throws java.sql.SQLException { |
223 |
|
int returnValue; |
224 |
0 |
statementQuery = p0; |
225 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
226 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
227 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
228 |
|
try { |
229 |
0 |
returnValue = passthru.executeUpdate(p0,p1); |
230 |
|
} finally { |
231 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
232 |
0 |
} |
233 |
0 |
return class="keyword">returnValue; |
234 |
|
} |
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
public int[] executeBatch() throws java.sql.SQLException { |
250 |
0 |
if(statementQuery == null) { |
251 |
0 |
return passthru.executeBatch(); |
252 |
|
} |
253 |
0 |
SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery); |
254 |
0 |
ExecutionTimer timer = new ExecutionTimer(executeCtx); |
255 |
0 |
StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); |
256 |
|
try { |
257 |
0 |
return(passthru.executeBatch()); |
258 |
|
} |
259 |
|
finally { |
260 |
0 |
MonitorFactory.getFacade().recordExecutionEnd(timer, col); |
261 |
|
} |
262 |
|
} |
263 |
|
|
264 |
|
protected P6Statement getP6Statement() { |
265 |
0 |
return this; |
266 |
|
} |
267 |
|
} |
268 |
|
|