01: package com.bm.utils;
02:
03: import java.sql.Connection;
04: import java.sql.PreparedStatement;
05: import java.sql.ResultSet;
06:
07: /**
08: * Untility class for SQL operations.
09: *
10: * @author Daniel Wiese
11: * @author <a href="mailto:daniel.wiese@siemens.com">Daniel Wiese</a>
12: *
13: */
14: public final class SQLUtils {
15:
16: /**
17: *
18: * Constructor.
19: */
20: private SQLUtils() {
21: // intentionally left blank
22: }
23:
24: /**
25: * Close the resources.
26: *
27: * @param con
28: * -connection
29: * @param prst -
30: * prepared statement
31: * @param rs -
32: * result set
33: */
34: public static void cleanup(Connection con, PreparedStatement prst,
35: ResultSet rs) {
36: if (rs != null) {
37: try {
38: rs.close();
39: } catch (Throwable e) {
40: }
41: }
42: if (prst != null) {
43: try {
44: prst.close();
45: } catch (Throwable e) {
46: }
47: }
48: if (con != null) {
49: try {
50: con.close();
51: } catch (Throwable e) {
52: }
53: }
54: }
55:
56: /**
57: * Close the resources.
58: *
59: * @param con
60: * -connection
61: */
62: public static void cleanup(Connection con) {
63: cleanup(con, null, null);
64: }
65:
66: /**
67: * Close the resources.
68: *
69: * @param con
70: * -connection
71: * @param prst -
72: * prepared statement
73: */
74: public static void cleanup(Connection con, PreparedStatement prst) {
75: cleanup(con, prst, null);
76: }
77:
78: }
|