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:
6
* 1. Redistributions of source code must retain copyright
7
* statements and notices. Redistributions must also contain a
8
* copy of this document.
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.
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.
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.
25
* 5. Due credit should be given to the Exolab Project
26
* (http://www.exolab.org/).
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.
41
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
43
* $Id: TwoPhaseConnection.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
47
package org.postgresql.xa;
50
import java.sql.SQLException;
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.
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
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.
70
* {@link #isCriticalError} is used to tell if an exception thrown by
71
* the connection is fatal and the connection should not be returned
75
* @author <a href="arkin@exoffice.com">Assaf Arkin</a>
78
public interface TwoPhaseConnection
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.
88
* @param flag True to enable SQL transactions (the default)
90
public void enableSQLTransactions( boolean flag );
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}.
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
103
public boolean prepare()
108
* Returns true if the error issued by this connection is a
109
* critical error and the connection should be terminated.
111
* @param except The exception thrown by this connection
113
public boolean isCriticalError( SQLException except );