1 package org.naftulin.configmgr.parsers;
2
3 import java.sql.Connection;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.sql.Statement;
7
8 import org.apache.log4j.Logger;
9
10 public class DBUtils {
11 public static final Logger log = Logger.getLogger(DBUtils.class);
12
13 public static final void closeConnection(final Connection c) {
14 try {
15 if (c!= null) {
16 c.close();
17 }
18 } catch(SQLException e) {
19 log.error("Error while closing db connection ", e);
20 }
21 }
22
23 public static final void closeStatement(final Statement stmt) {
24 try {
25 if (stmt!= null) {
26 stmt.close();
27 }
28 } catch(SQLException e) {
29 log.error("Error while closing db statement ", e);
30 }
31 }
32
33 public static final void closeResultSet(final ResultSet rs) {
34 try {
35 if (rs!= null) {
36 rs.close();
37 }
38 } catch(SQLException e) {
39 log.error("Error while closing db result set ", e);
40 }
41 }
42 }