1 22 23 24 package com.mchange.v1.db.sql; 25 26 import java.sql.*; 27 import com.mchange.v2.log.*; 28 29 public final class ConnectionUtils 30 { 31 private final static MLogger logger = MLog.getLogger( ConnectionUtils.class ); 32 33 37 public static boolean attemptClose(Connection con) 38 { 39 try 40 { 41 if (con != null) con.close(); 42 return true; 44 } 45 catch (SQLException e) 46 { 47 50 if ( logger.isLoggable( MLevel.WARNING ) ) 51 logger.log( MLevel.WARNING, "Connection close FAILED.", e ); 52 return false; 53 } 54 } 55 56 public static boolean attemptRollback(Connection con) 57 { 58 try 59 { 60 if (con != null) con.rollback(); 61 return true; 62 } 63 catch (SQLException e) 64 { 65 67 if ( logger.isLoggable( MLevel.WARNING ) ) 68 logger.log( MLevel.WARNING, "Rollback FAILED.", e ); 69 return false; 70 } 71 } 72 73 private ConnectionUtils() 74 {} 75 } 76 | Popular Tags |