Class Closer


  • public final class Closer
    extends Object
    Utility class for closing JDBC resources.
    • Method Detail

      • close

        public static void close​(Connection con)
        Close given connection, if it is null does nothing.
        Parameters:
        con - Connection
      • close

        public static void close​(Connection con,
                                 Logger logger)
        Close given connection, if it is null does nothing. Exceptions that occur when closing are logged to given logger
        Parameters:
        con - Connection
        logger - Logger to log to (optional)
      • close

        public static void close​(PreparedStatement ps)
        Close given prepared statement, if it is null does nothing.
        Parameters:
        ps - Statement
      • close

        public static void close​(PreparedStatement ps,
                                 Logger logger)
        Close given prepared statement, if it is null does nothing. Exceptions that occur when closing are logged to given logger
        Parameters:
        ps - Statement
        logger - Logger to log to (optional)
      • close

        public static void close​(Statement stmt)
        Close given statement, if it is null does nothing.
        Parameters:
        stmt - Statement
      • close

        public static void close​(Statement stmt,
                                 Logger logger)
        Close given statement, if it is null does nothing. Exceptions that occur when closing are logged to given logger
        Parameters:
        stmt - Statement
        logger - Logger to log to (optional)
      • close

        public static void close​(ResultSet rs)
        Close given ResultSet, if it is null does nothing.
        Parameters:
        rs - ResultSet
      • close

        public static void close​(ResultSet rs,
                                 Logger logger)
        Close given ResultSet, if it is null does nothing. Exceptions that occur when closing are logged to given logger
        Parameters:
        rs - ResultSet
        logger - Logger to log to (optional)