1 package com.ning.metrics.goodwill.dao;
2
3
4 import com.ning.metrics.goodwill.store.MySQLStore;
5 import org.apache.log4j.Logger;
6
7 import java.sql.Connection;
8 import java.sql.ResultSet;
9 import java.sql.SQLException;
10 import java.sql.Statement;
11
12 public final class DAOUtil
13 {
14 private static Logger log = Logger.getLogger(MySQLStore.class);
15
16
17
18
19
20
21 public static void close(Connection connection)
22 {
23 if (connection != null) {
24 try {
25 connection.close();
26 }
27 catch (SQLException e) {
28 log.warn("Closing Connection failed: " + e.getLocalizedMessage(), e);
29 }
30 }
31 }
32
33
34
35
36
37
38 public static void close(Statement statement)
39 {
40 if (statement != null) {
41 try {
42 statement.close();
43 }
44 catch (SQLException e) {
45 log.warn("Closing Statement failed: " + e.getLocalizedMessage(), e);
46 }
47 }
48 }
49
50
51
52
53
54
55 public static void close(ResultSet resultSet)
56 {
57 if (resultSet != null) {
58 try {
59 resultSet.close();
60 }
61 catch (SQLException e) {
62 log.warn("Closing ResultSet failed: " + e.getLocalizedMessage(), e);
63 }
64 }
65 }
66
67
68
69
70
71
72
73 public static void close(Connection connection, Statement statement)
74 {
75 close(statement);
76 close(connection);
77 }
78
79
80
81
82
83
84
85
86 public static void close(Connection connection, Statement statement, ResultSet resultSet)
87 {
88 close(resultSet);
89 close(statement);
90 close(connection);
91 }
92 }