View Javadoc
1   /*
2    * To change this license header, choose License Headers in Project Properties.
3    * To change this template file, choose Tools | Templates
4    * and open the template in the editor.
5    */
6   package org.miloss.fgsms.common;
7   
8   import java.sql.Connection;
9   import java.sql.PreparedStatement;
10  import java.sql.ResultSet;
11  import org.apache.log4j.Level;
12  
13  
14  /**
15   *
16   * @author AO
17   */
18  public class DBUtils {
19  
20      static Logger log = Logger.getLogger("fgsms.DBUtils");
21  
22      public static void safeClose(Connection con) {
23          if (con != null) {
24              try {
25                  con.close();
26              } catch (Throwable ex) {
27                  log.log(Level.INFO, null, ex);
28              }
29          }
30      }
31      
32      public static void safeClose(ResultSet con) {
33          if (con != null) {
34              try {
35                  con.close();
36              } catch (Throwable ex) {
37                  log.log(Level.INFO, null, ex);
38              }
39          }
40      }
41      
42      public static void safeClose(PreparedStatement con) {
43          if (con != null) {
44              try {
45                  con.close();
46              } catch (Throwable ex) {
47                  log.log(Level.INFO, null, ex);
48              }
49          }
50      }
51  }