Package org.jooq.impl

Class DefaultConnectionProvider

  • All Implemented Interfaces:
    ConnectionProvider

    public class DefaultConnectionProvider
    extends java.lang.Object
    implements ConnectionProvider
    A default implementation for ConnectionProvider.

    This implementation just wraps a JDBC Connection and provides jOOQ with the same connection for every query. jOOQ will not call any transaction-related methods on the supplied connection. Instead, jOOQ provides you with convenient access to those methods, wrapping any checked SQLException into an unchecked DataAccessException

    Author:
    Aaron Digulla, Lukas Eder
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.sql.Connection acquire()
      Acquire a connection from the connection lifecycle handler.
      void commit()
      Convenience method to access Connection.commit().
      protected void finalize()  
      boolean getAutoCommit()
      Convenience method to access Connection.getAutoCommit().
      int getHoldability()
      Convenience method to access Connection.getHoldability().
      int getTransactionIsolation()
      Convenience method to access Connection.getTransactionIsolation().
      boolean isReadOnly()
      Convenience method to access Connection.isReadOnly().
      void release​(java.sql.Connection released)
      Release a connection to the connection lifecycle handler.
      void releaseSavepoint​(java.sql.Savepoint savepoint)
      Convenience method to access Connection.releaseSavepoint(Savepoint).
      void rollback()
      Convenience method to access Connection.rollback().
      void rollback​(java.sql.Savepoint savepoint)
      Convenience method to access Connection.rollback(Savepoint).
      void setAutoCommit​(boolean autoCommit)
      Convenience method to access Connection.setAutoCommit(boolean).
      void setConnection​(java.sql.Connection connection)  
      void setHoldability​(int holdability)
      Convenience method to access Connection.setHoldability(int).
      void setReadOnly​(boolean readOnly)
      Convenience method to access Connection.setReadOnly(boolean).
      java.sql.Savepoint setSavepoint()
      Convenience method to access Connection.setSavepoint().
      java.sql.Savepoint setSavepoint​(java.lang.String name)
      Convenience method to access Connection.setSavepoint(String).
      void setTransactionIsolation​(int level)
      Convenience method to access Connection.setTransactionIsolation(int).
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultConnectionProvider

        public DefaultConnectionProvider​(java.sql.Connection connection)
    • Method Detail

      • acquire

        public final java.sql.Connection acquire()
        Description copied from interface: ConnectionProvider
        Acquire a connection from the connection lifecycle handler.

        This method is called by jOOQ exactly once per execution lifecycle, i.e. per ExecuteContext. Implementations may freely chose, whether subsequent calls to this method:

        • return the same connection instance
        • return the same connection instance for the same thread
        • return the same connection instance for the same transaction (e.g. a javax.transaction.UserTransaction)
        • return a fresh connection instance every time

        jOOQ will guarantee that every acquired connection is released through ConnectionProvider.release(Connection) exactly once.

        Specified by:
        acquire in interface ConnectionProvider
        Returns:
        A connection for the current ExecuteContext.
      • release

        public final void release​(java.sql.Connection released)
        Description copied from interface: ConnectionProvider
        Release a connection to the connection lifecycle handler.

        jOOQ will guarantee that every acquired connection is released exactly once.

        Specified by:
        release in interface ConnectionProvider
        Parameters:
        released - A connection that was previously obtained from ConnectionProvider.acquire(). This is never null.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • setConnection

        public final void setConnection​(java.sql.Connection connection)
      • setSavepoint

        public final java.sql.Savepoint setSavepoint​(java.lang.String name)
                                              throws DataAccessException
        Convenience method to access Connection.setSavepoint(String).
        Throws:
        DataAccessException
      • releaseSavepoint

        public final void releaseSavepoint​(java.sql.Savepoint savepoint)
                                    throws DataAccessException
        Convenience method to access Connection.releaseSavepoint(Savepoint).
        Throws:
        DataAccessException
      • setAutoCommit

        public final void setAutoCommit​(boolean autoCommit)
                                 throws DataAccessException
        Convenience method to access Connection.setAutoCommit(boolean).
        Throws:
        DataAccessException
      • setTransactionIsolation

        public final void setTransactionIsolation​(int level)
                                           throws DataAccessException
        Convenience method to access Connection.setTransactionIsolation(int).
        Throws:
        DataAccessException
      • getTransactionIsolation

        public final int getTransactionIsolation()
                                          throws DataAccessException
        Convenience method to access Connection.getTransactionIsolation().
        Throws:
        DataAccessException