View Javadoc
1   /**
2    *    Copyright 2009-2019 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.transaction;
17  
18  import java.sql.Connection;
19  import java.sql.SQLException;
20  
21  /**
22   * Wraps a database connection.
23   * Handles the connection lifecycle that comprises: its creation, preparation, commit/rollback and close.
24   *
25   * @author Clinton Begin
26   */
27  public interface Transaction {
28  
29    /**
30     * Retrieve inner database connection.
31     * @return DataBase connection
32     * @throws SQLException
33     */
34    Connection getConnection() throws SQLException;
35  
36    /**
37     * Commit inner database connection.
38     * @throws SQLException
39     */
40    void commit() throws SQLException;
41  
42    /**
43     * Rollback inner database connection.
44     * @throws SQLException
45     */
46    void rollback() throws SQLException;
47  
48    /**
49     * Close inner database connection.
50     * @throws SQLException
51     */
52    void close() throws SQLException;
53  
54    /**
55     * Get transaction timeout if set.
56     * @throws SQLException
57     */
58    Integer getTimeout() throws SQLException;
59  
60  }