~ubuntu-branches/ubuntu/wily/libpgjava/wily

« back to all changes in this revision

Viewing changes to src/interfaces/jdbc/org/postgresql/xa/TwoPhaseConnection.java

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Gybas
  • Date: 2002-02-06 23:43:06 UTC
  • Revision ID: james.westby@ubuntu.com-20020206234306-hsg7suqr8q56qg40
Tags: upstream-7.2
ImportĀ upstreamĀ versionĀ 7.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* Redistribution and use of this software and associated documentation
 
3
* ("Software"), with or without modification, are permitted provided
 
4
* that the following conditions are met:
 
5
*
 
6
* 1. Redistributions of source code must retain copyright
 
7
*        statements and notices.  Redistributions must also contain a
 
8
*        copy of this document.
 
9
*
 
10
* 2. Redistributions in binary form must reproduce the
 
11
*        above copyright notice, this list of conditions and the
 
12
*        following disclaimer in the documentation and/or other
 
13
*        materials provided with the distribution.
 
14
*
 
15
* 3. The name "Exolab" must not be used to endorse or promote
 
16
*        products derived from this Software without prior written
 
17
*        permission of Exoffice Technologies.  For written permission,
 
18
*        please contact info@exolab.org.
 
19
*
 
20
* 4. Products derived from this Software may not be called "Exolab"
 
21
*        nor may "Exolab" appear in their names without prior written
 
22
*        permission of Exoffice Technologies. Exolab is a registered
 
23
*        trademark of Exoffice Technologies.
 
24
*
 
25
* 5. Due credit should be given to the Exolab Project
 
26
*        (http://www.exolab.org/).
 
27
*
 
28
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
 
29
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 
30
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 
31
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.      IN NO EVENT SHALL
 
32
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 
33
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
34
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
35
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
36
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 
37
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
38
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 
39
* OF THE POSSIBILITY OF SUCH DAMAGE.
 
40
*
 
41
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
 
42
*
 
43
* $Id: TwoPhaseConnection.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
 
44
*/
 
45
 
 
46
 
 
47
package org.postgresql.xa;
 
48
 
 
49
 
 
50
import java.sql.SQLException;
 
51
 
 
52
 
 
53
/*
 
54
 * Defines two-phase commit support for a JDBC connection used by
 
55
 * {@link XAConnection}. A JDBC connection that can implement any of
 
56
 * these features should extend this interface and attempt to
 
57
 * implement as much as it can.
 
58
 * <p>
 
59
 * {@link #prepare} is used as part of the two phase commit protocol
 
60
 * to determine whether the transaction can commit or must rollback.
 
61
 * Failure to implement this method will cause all connections to vote
 
62
 * for commit, whether or not they can actually commit, leading to
 
63
 * mixed heuristics.
 
64
 * <p>
 
65
 * {@link #enableSQLTransactions} allows the SQL begin/commit/rollback
 
66
 * commands to be disabled for the duration of a transaction managed
 
67
 * through an {@link javax.transaction.xaXAResource}, preventing the
 
68
 * application from demarcating transactions directly.
 
69
 * <p>
 
70
 * {@link #isCriticalError} is used to tell if an exception thrown by
 
71
 * the connection is fatal and the connection should not be returned
 
72
 * to the pool.
 
73
 *
 
74
 *
 
75
 * @author <a href="arkin@exoffice.com">Assaf Arkin</a>
 
76
 * @version 1.0
 
77
 */
 
78
public interface TwoPhaseConnection
 
79
{
 
80
 
 
81
 
 
82
        /*
 
83
         * Enables or disables transaction demarcation through SQL commit
 
84
         * and rollback. When the connection falls under control of
 
85
         * {@link XAConnection}, SQL commit/rollback commands will be
 
86
         * disabled to prevent direct transaction demarcation.
 
87
         *
 
88
         * @param flag True to enable SQL transactions (the default)
 
89
         */
 
90
        public void enableSQLTransactions( boolean flag );
 
91
 
 
92
 
 
93
        /*
 
94
         * Called to prepare the transaction for commit. Returns true if
 
95
         * the transaction is prepared, false if the transaction is
 
96
         * read-only. If the transaction has been marked for rollback,
 
97
         * throws a {@link RollbackException}.
 
98
         *
 
99
         * @return True if can commit, false if read-only
 
100
         * @throws SQLException If transaction has been marked for
 
101
         *       rollback or cannot commit for any other reason
 
102
         */
 
103
        public boolean prepare()
 
104
        throws SQLException;
 
105
 
 
106
 
 
107
        /*
 
108
         * Returns true if the error issued by this connection is a
 
109
         * critical error and the connection should be terminated.
 
110
         *
 
111
         * @param except The exception thrown by this connection
 
112
         */
 
113
        public boolean isCriticalError( SQLException except );
 
114
 
 
115
 
 
116
}