|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| package org.objectledge.database.impl; |
|
30 |
| |
|
31 |
| import java.io.InputStream; |
|
32 |
| import java.io.Reader; |
|
33 |
| import java.math.BigDecimal; |
|
34 |
| import java.net.URL; |
|
35 |
| import java.sql.Array; |
|
36 |
| import java.sql.Blob; |
|
37 |
| import java.sql.CallableStatement; |
|
38 |
| import java.sql.Clob; |
|
39 |
| import java.sql.Date; |
|
40 |
| import java.sql.Ref; |
|
41 |
| import java.sql.SQLException; |
|
42 |
| import java.sql.Time; |
|
43 |
| import java.sql.Timestamp; |
|
44 |
| import java.util.Calendar; |
|
45 |
| import java.util.HashMap; |
|
46 |
| import java.util.List; |
|
47 |
| import java.util.Map; |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| @SuppressWarnings("deprecation") |
|
56 |
| public class DelegatingCallableStatement |
|
57 |
| extends DelegatingPreparedStatement |
|
58 |
| implements CallableStatement |
|
59 |
| { |
|
60 |
| |
|
61 |
| private final CallableStatement callableStatement; |
|
62 |
| |
|
63 |
| private final Map<String, Object> parameterMap = new HashMap<String, Object>(); |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
0
| public DelegatingCallableStatement(CallableStatement callableStatement, String sql)
|
|
72 |
| { |
|
73 |
0
| super(callableStatement, sql);
|
|
74 |
0
| this.callableStatement = callableStatement;
|
|
75 |
| } |
|
76 |
| |
|
77 |
0
| private void setParameter(String parameterName, Object value)
|
|
78 |
| { |
|
79 |
0
| parameterMap.put(parameterName, value);
|
|
80 |
| } |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
0
| @Override
|
|
86 |
| protected void clearParameters2() |
|
87 |
| { |
|
88 |
0
| super.clearParameters2();
|
|
89 |
0
| parameterMap.clear();
|
|
90 |
| } |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
0
| @Override
|
|
96 |
| protected String getBody() |
|
97 |
| { |
|
98 |
0
| List<Object> parameterList = getParameterList();
|
|
99 |
0
| StringBuilder body = new StringBuilder();
|
|
100 |
0
| body.append(getSQL());
|
|
101 |
0
| if(!parameterList.isEmpty() || !parameterMap.isEmpty())
|
|
102 |
| { |
|
103 |
0
| body.append(" with ");
|
|
104 |
| } |
|
105 |
0
| if(!parameterList.isEmpty())
|
|
106 |
| { |
|
107 |
0
| body.append(parameterList.toString());
|
|
108 |
| } |
|
109 |
0
| if(!parameterList.isEmpty() && !parameterMap.isEmpty())
|
|
110 |
| { |
|
111 |
0
| body.append(", ");
|
|
112 |
| } |
|
113 |
0
| if(!parameterMap.isEmpty())
|
|
114 |
| { |
|
115 |
0
| body.append(parameterMap.toString());
|
|
116 |
| } |
|
117 |
0
| return body.toString();
|
|
118 |
| } |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
0
| public void registerOutParameter(int parameterIndex, int sqlType)
|
|
126 |
| throws SQLException |
|
127 |
| { |
|
128 |
0
| callableStatement.registerOutParameter(parameterIndex, sqlType);
|
|
129 |
| } |
|
130 |
| |
|
131 |
| |
|
132 |
| |
|
133 |
| |
|
134 |
0
| public void registerOutParameter(int parameterIndex, int sqlType, int scale)
|
|
135 |
| throws SQLException |
|
136 |
| { |
|
137 |
0
| callableStatement.registerOutParameter(parameterIndex, sqlType, scale);
|
|
138 |
| } |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
0
| public void registerOutParameter(int paramIndex, int sqlType, String typeName)
|
|
144 |
| throws SQLException |
|
145 |
| { |
|
146 |
0
| callableStatement.registerOutParameter(paramIndex, sqlType, typeName);
|
|
147 |
| } |
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
0
| public void registerOutParameter(String parameterName, int sqlType)
|
|
153 |
| throws SQLException |
|
154 |
| { |
|
155 |
0
| callableStatement.registerOutParameter(parameterName, sqlType);
|
|
156 |
| } |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
0
| public void registerOutParameter(String parameterName, int sqlType, int scale)
|
|
162 |
| throws SQLException |
|
163 |
| { |
|
164 |
0
| callableStatement.registerOutParameter(parameterName, sqlType, scale);
|
|
165 |
| } |
|
166 |
| |
|
167 |
| |
|
168 |
| |
|
169 |
| |
|
170 |
0
| public void registerOutParameter(String parameterName, int sqlType, String typeName)
|
|
171 |
| throws SQLException |
|
172 |
| { |
|
173 |
0
| callableStatement.registerOutParameter(parameterName, sqlType, typeName);
|
|
174 |
| } |
|
175 |
| |
|
176 |
| |
|
177 |
| |
|
178 |
| |
|
179 |
0
| public boolean wasNull()
|
|
180 |
| throws SQLException |
|
181 |
| { |
|
182 |
0
| return callableStatement.wasNull();
|
|
183 |
| } |
|
184 |
| |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
0
| public String getString(int parameterIndex)
|
|
189 |
| throws SQLException |
|
190 |
| { |
|
191 |
0
| return callableStatement.getString(parameterIndex);
|
|
192 |
| } |
|
193 |
| |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
0
| public boolean getBoolean(int parameterIndex)
|
|
198 |
| throws SQLException |
|
199 |
| { |
|
200 |
0
| return callableStatement.getBoolean(parameterIndex);
|
|
201 |
| } |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
0
| public byte getByte(int parameterIndex)
|
|
207 |
| throws SQLException |
|
208 |
| { |
|
209 |
0
| return callableStatement.getByte(parameterIndex);
|
|
210 |
| } |
|
211 |
| |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
0
| public short getShort(int parameterIndex)
|
|
216 |
| throws SQLException |
|
217 |
| { |
|
218 |
0
| return callableStatement.getShort(parameterIndex);
|
|
219 |
| } |
|
220 |
| |
|
221 |
| |
|
222 |
| |
|
223 |
| |
|
224 |
0
| public int getInt(int parameterIndex)
|
|
225 |
| throws SQLException |
|
226 |
| { |
|
227 |
0
| return callableStatement.getInt(parameterIndex);
|
|
228 |
| } |
|
229 |
| |
|
230 |
| |
|
231 |
| |
|
232 |
| |
|
233 |
0
| public long getLong(int parameterIndex)
|
|
234 |
| throws SQLException |
|
235 |
| { |
|
236 |
0
| return callableStatement.getLong(parameterIndex);
|
|
237 |
| } |
|
238 |
| |
|
239 |
| |
|
240 |
| |
|
241 |
| |
|
242 |
0
| public float getFloat(int parameterIndex)
|
|
243 |
| throws SQLException |
|
244 |
| { |
|
245 |
0
| return callableStatement.getFloat(parameterIndex);
|
|
246 |
| } |
|
247 |
| |
|
248 |
| |
|
249 |
| |
|
250 |
| |
|
251 |
0
| public double getDouble(int parameterIndex)
|
|
252 |
| throws SQLException |
|
253 |
| { |
|
254 |
0
| return callableStatement.getDouble(parameterIndex);
|
|
255 |
| } |
|
256 |
| |
|
257 |
| |
|
258 |
| |
|
259 |
| |
|
260 |
0
| public BigDecimal getBigDecimal(int parameterIndex)
|
|
261 |
| throws SQLException |
|
262 |
| { |
|
263 |
0
| return callableStatement.getBigDecimal(parameterIndex);
|
|
264 |
| } |
|
265 |
| |
|
266 |
| |
|
267 |
| |
|
268 |
| |
|
269 |
0
| public BigDecimal getBigDecimal(int parameterIndex, int scale)
|
|
270 |
| throws SQLException |
|
271 |
| { |
|
272 |
0
| return callableStatement.getBigDecimal(parameterIndex, scale);
|
|
273 |
| } |
|
274 |
| |
|
275 |
| |
|
276 |
| |
|
277 |
| |
|
278 |
0
| public byte[] getBytes(int parameterIndex)
|
|
279 |
| throws SQLException |
|
280 |
| { |
|
281 |
0
| return callableStatement.getBytes(parameterIndex);
|
|
282 |
| } |
|
283 |
| |
|
284 |
| |
|
285 |
| |
|
286 |
| |
|
287 |
0
| public Date getDate(int parameterIndex)
|
|
288 |
| throws SQLException |
|
289 |
| { |
|
290 |
0
| return callableStatement.getDate(parameterIndex);
|
|
291 |
| } |
|
292 |
| |
|
293 |
| |
|
294 |
| |
|
295 |
| |
|
296 |
0
| public Time getTime(int parameterIndex)
|
|
297 |
| throws SQLException |
|
298 |
| { |
|
299 |
0
| return callableStatement.getTime(parameterIndex);
|
|
300 |
| } |
|
301 |
| |
|
302 |
| |
|
303 |
| |
|
304 |
| |
|
305 |
0
| public Timestamp getTimestamp(int parameterIndex)
|
|
306 |
| throws SQLException |
|
307 |
| { |
|
308 |
0
| return callableStatement.getTimestamp(parameterIndex);
|
|
309 |
| } |
|
310 |
| |
|
311 |
| |
|
312 |
| |
|
313 |
| |
|
314 |
0
| public Object getObject(int parameterIndex)
|
|
315 |
| throws SQLException |
|
316 |
| { |
|
317 |
0
| return callableStatement.getObject(parameterIndex);
|
|
318 |
| } |
|
319 |
| |
|
320 |
| |
|
321 |
| |
|
322 |
| |
|
323 |
0
| public Object getObject(int parameterIndex, Map<String, Class<?>> typeMap)
|
|
324 |
| throws SQLException |
|
325 |
| { |
|
326 |
0
| return callableStatement.getObject(parameterIndex, typeMap);
|
|
327 |
| } |
|
328 |
| |
|
329 |
| |
|
330 |
| |
|
331 |
| |
|
332 |
0
| public Ref getRef(int i)
|
|
333 |
| throws SQLException |
|
334 |
| { |
|
335 |
0
| return callableStatement.getRef(i);
|
|
336 |
| } |
|
337 |
| |
|
338 |
| |
|
339 |
| |
|
340 |
| |
|
341 |
0
| public Blob getBlob(int i)
|
|
342 |
| throws SQLException |
|
343 |
| { |
|
344 |
0
| return callableStatement.getBlob(i);
|
|
345 |
| } |
|
346 |
| |
|
347 |
| |
|
348 |
| |
|
349 |
| |
|
350 |
0
| public Clob getClob(int i)
|
|
351 |
| throws SQLException |
|
352 |
| { |
|
353 |
0
| return callableStatement.getClob(i);
|
|
354 |
| } |
|
355 |
| |
|
356 |
| |
|
357 |
| |
|
358 |
| |
|
359 |
0
| public Array getArray(int i)
|
|
360 |
| throws SQLException |
|
361 |
| { |
|
362 |
0
| return callableStatement.getArray(i);
|
|
363 |
| } |
|
364 |
| |
|
365 |
| |
|
366 |
| |
|
367 |
| |
|
368 |
0
| public Date getDate(int parameterIndex, Calendar cal)
|
|
369 |
| throws SQLException |
|
370 |
| { |
|
371 |
0
| return callableStatement.getDate(parameterIndex, cal);
|
|
372 |
| } |
|
373 |
| |
|
374 |
| |
|
375 |
| |
|
376 |
| |
|
377 |
0
| public Time getTime(int parameterIndex, Calendar cal)
|
|
378 |
| throws SQLException |
|
379 |
| { |
|
380 |
0
| return callableStatement.getTime(parameterIndex, cal);
|
|
381 |
| } |
|
382 |
| |
|
383 |
| |
|
384 |
| |
|
385 |
| |
|
386 |
0
| public Timestamp getTimestamp(int parameterIndex, Calendar cal)
|
|
387 |
| throws SQLException |
|
388 |
| { |
|
389 |
0
| return callableStatement.getTimestamp(parameterIndex, cal);
|
|
390 |
| } |
|
391 |
| |
|
392 |
| |
|
393 |
| |
|
394 |
| |
|
395 |
0
| public URL getURL(int parameterIndex)
|
|
396 |
| throws SQLException |
|
397 |
| { |
|
398 |
0
| return callableStatement.getURL(parameterIndex);
|
|
399 |
| } |
|
400 |
| |
|
401 |
| |
|
402 |
| |
|
403 |
| |
|
404 |
0
| public String getString(String parameterName)
|
|
405 |
| throws SQLException |
|
406 |
| { |
|
407 |
0
| return callableStatement.getString(parameterName);
|
|
408 |
| } |
|
409 |
| |
|
410 |
| |
|
411 |
| |
|
412 |
| |
|
413 |
0
| public boolean getBoolean(String parameterName)
|
|
414 |
| throws SQLException |
|
415 |
| { |
|
416 |
0
| return callableStatement.getBoolean(parameterName);
|
|
417 |
| } |
|
418 |
| |
|
419 |
| |
|
420 |
| |
|
421 |
| |
|
422 |
0
| public byte getByte(String parameterName)
|
|
423 |
| throws SQLException |
|
424 |
| { |
|
425 |
0
| return callableStatement.getByte(parameterName);
|
|
426 |
| } |
|
427 |
| |
|
428 |
| |
|
429 |
| |
|
430 |
| |
|
431 |
0
| public short getShort(String parameterName)
|
|
432 |
| throws SQLException |
|
433 |
| { |
|
434 |
0
| return callableStatement.getShort(parameterName);
|
|
435 |
| } |
|
436 |
| |
|
437 |
| |
|
438 |
| |
|
439 |
| |
|
440 |
0
| public int getInt(String parameterName)
|
|
441 |
| throws SQLException |
|
442 |
| { |
|
443 |
0
| return callableStatement.getInt(parameterName);
|
|
444 |
| } |
|
445 |
| |
|
446 |
| |
|
447 |
| |
|
448 |
| |
|
449 |
0
| public long getLong(String parameterName)
|
|
450 |
| throws SQLException |
|
451 |
| { |
|
452 |
0
| return callableStatement.getLong(parameterName);
|
|
453 |
| } |
|
454 |
| |
|
455 |
| |
|
456 |
| |
|
457 |
| |
|
458 |
0
| public float getFloat(String parameterName)
|
|
459 |
| throws SQLException |
|
460 |
| { |
|
461 |
0
| return callableStatement.getFloat(parameterName);
|
|
462 |
| } |
|
463 |
| |
|
464 |
| |
|
465 |
| |
|
466 |
| |
|
467 |
0
| public double getDouble(String parameterName)
|
|
468 |
| throws SQLException |
|
469 |
| { |
|
470 |
0
| return callableStatement.getDouble(parameterName);
|
|
471 |
| } |
|
472 |
| |
|
473 |
| |
|
474 |
| |
|
475 |
| |
|
476 |
0
| public byte[] getBytes(String parameterName)
|
|
477 |
| throws SQLException |
|
478 |
| { |
|
479 |
0
| return callableStatement.getBytes(parameterName);
|
|
480 |
| } |
|
481 |
| |
|
482 |
| |
|
483 |
| |
|
484 |
| |
|
485 |
0
| public Date getDate(String parameterName)
|
|
486 |
| throws SQLException |
|
487 |
| { |
|
488 |
0
| return callableStatement.getDate(parameterName);
|
|
489 |
| } |
|
490 |
| |
|
491 |
| |
|
492 |
| |
|
493 |
| |
|
494 |
0
| public Time getTime(String parameterName)
|
|
495 |
| throws SQLException |
|
496 |
| { |
|
497 |
0
| return callableStatement.getTime(parameterName);
|
|
498 |
| } |
|
499 |
| |
|
500 |
| |
|
501 |
| |
|
502 |
| |
|
503 |
0
| public Timestamp getTimestamp(String parameterName)
|
|
504 |
| throws SQLException |
|
505 |
| { |
|
506 |
0
| return callableStatement.getTimestamp(parameterName);
|
|
507 |
| } |
|
508 |
| |
|
509 |
| |
|
510 |
| |