Interface ConnectionFactory

  • All Known Implementing Classes:
    SingleConnectionFactory
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface ConnectionFactory
    Supplies Connection instances to a created Handle and allows custom close handling.
    • Method Detail

      • openConnection

        java.sql.Connection openConnection()
                                    throws java.sql.SQLException
        Opens a connection.
        Returns:
        A Connection object.
        Throws:
        java.sql.SQLException - if anything goes wrong
      • closeConnection

        default void closeConnection​(java.sql.Connection conn)
                              throws java.sql.SQLException
        Closes a connection.
        Parameters:
        conn - A Connection object.
        Throws:
        java.sql.SQLException - if anything goes wrong
      • getCleanableFor

        default Cleanable getCleanableFor​(java.sql.Connection conn)
        Returns a Cleanable that will close the connection and release all necessary resources.
        Parameters:
        conn - A Connection object.
        Returns:
        A Cleanable instance. Calling the Cleanable.close() method will close the connection and release all resources.