Class JdbcTransaction

  • All Implemented Interfaces:
    Transaction

    public class JdbcTransaction
    extends java.lang.Object
    implements Transaction
    Transaction that makes use of the JDBC commit and rollback facilities directly. It relies on the connection retrieved from the dataSource to manage the scope of the transaction. Delays connection retrieval until getConnection() is called. Ignores commit or rollback requests when autocommit is on.
    Author:
    Clinton Begin
    See Also:
    JdbcTransactionFactory
    • Field Detail

      • connection

        protected java.sql.Connection connection
      • dataSource

        protected javax.sql.DataSource dataSource
      • autoCommit

        protected boolean autoCommit
    • Constructor Detail

      • JdbcTransaction

        public JdbcTransaction​(javax.sql.DataSource ds,
                               TransactionIsolationLevel desiredLevel,
                               boolean desiredAutoCommit)
      • JdbcTransaction

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

      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException
        Description copied from interface: Transaction
        Retrieve inner database connection.
        Specified by:
        getConnection in interface Transaction
        Returns:
        DataBase connection
        Throws:
        java.sql.SQLException
      • commit

        public void commit()
                    throws java.sql.SQLException
        Description copied from interface: Transaction
        Commit inner database connection.
        Specified by:
        commit in interface Transaction
        Throws:
        java.sql.SQLException
      • rollback

        public void rollback()
                      throws java.sql.SQLException
        Description copied from interface: Transaction
        Rollback inner database connection.
        Specified by:
        rollback in interface Transaction
        Throws:
        java.sql.SQLException
      • close

        public void close()
                   throws java.sql.SQLException
        Description copied from interface: Transaction
        Close inner database connection.
        Specified by:
        close in interface Transaction
        Throws:
        java.sql.SQLException
      • setDesiredAutoCommit

        protected void setDesiredAutoCommit​(boolean desiredAutoCommit)
      • resetAutoCommit

        protected void resetAutoCommit()
      • openConnection

        protected void openConnection()
                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getTimeout

        public java.lang.Integer getTimeout()
                                     throws java.sql.SQLException
        Description copied from interface: Transaction
        Get transaction timeout if set.
        Specified by:
        getTimeout in interface Transaction
        Throws:
        java.sql.SQLException