1 21 package net.mlw.vlh.adapter.jdbc.util; 22 23 import java.sql.Connection ; 24 import java.sql.ResultSet ; 25 import java.sql.Statement ; 26 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 30 36 public final class JdbcUtil 37 { 38 39 private static final Log LOGGER = LogFactory.getFactory().getInstance(JdbcUtil.class); 40 41 42 private JdbcUtil() 43 { 44 45 } 46 47 52 public static void close(Statement statement, Connection connection) 53 { 54 try 55 { 56 statement.close(); 57 } 58 catch (Exception ignore) 59 { 60 LOGGER.info(ignore); 61 } 62 try 63 { 64 connection.close(); 65 } 66 catch (Exception ignore) 67 { 68 LOGGER.info(ignore); 69 } 70 } 71 72 78 public static void close(ResultSet result, Statement statement, Connection connection) 79 { 80 if (result != null) 81 try 82 { 83 result.close(); 84 } 85 catch (Exception ignore) 86 { 87 LOGGER.info(ignore); 88 } 89 if (statement != null) 90 try 91 { 92 statement.close(); 93 } 94 catch (Exception ignore) 95 { 96 LOGGER.info(ignore); 97 } 98 if (connection != null) 99 try 100 { 101 connection.close(); 102 } 103 catch (Exception ignore) 104 { 105 LOGGER.info(ignore); 106 } 107 } 108 } | Popular Tags |