KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > client > am > XaException


1 /*
2
3    Derby - Class org.apache.derby.client.am.XaException
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20 */

21
22 package org.apache.derby.client.am;
23
24
25 public class XaException extends javax.transaction.xa.XAException JavaDoc implements Diagnosable {
26     java.lang.Throwable JavaDoc throwable_ = null;
27
28     //-----------------constructors-----------------------------------------------
29

30     public XaException(LogWriter logWriter) {
31         super();
32         if (logWriter != null) {
33             logWriter.traceDiagnosable(this);
34         }
35     }
36
37     public XaException(LogWriter logWriter, java.lang.Throwable JavaDoc throwable) {
38         super();
39         throwable_ = throwable;
40         if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
41                 (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
42                 (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
43
initCause(throwable);
44         }
45         if (logWriter != null) {
46             logWriter.traceDiagnosable(this);
47         }
48     }
49
50     public XaException(LogWriter logWriter, int errcode) {
51         super();
52         errorCode = errcode;
53         if (logWriter != null) {
54             logWriter.traceDiagnosable(this);
55         }
56     }
57
58     public XaException(LogWriter logWriter, java.lang.Throwable JavaDoc throwable, int errcode) {
59         super();
60         errorCode = errcode;
61         throwable_ = throwable;
62         if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
63                 (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
64                 (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
65
initCause(throwable);
66         }
67         if (logWriter != null) {
68             logWriter.traceDiagnosable(this);
69         }
70     }
71
72     public XaException(LogWriter logWriter, String JavaDoc s) {
73         super(s);
74         if (logWriter != null) {
75             logWriter.traceDiagnosable(this);
76         }
77     }
78
79     public XaException(LogWriter logWriter, java.lang.Throwable JavaDoc throwable, String JavaDoc s) {
80         super(s);
81         throwable_ = throwable;
82         if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) &&
83                 (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4)) ||
84                 (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
85
initCause(throwable);
86         }
87         if (logWriter != null) {
88             logWriter.traceDiagnosable(this);
89         }
90     }
91
92     public Sqlca getSqlca() {
93         return null;
94     }
95
96     public java.lang.Throwable JavaDoc getThrowable() {
97         return throwable_;
98     }
99
100     public void printTrace(java.io.PrintWriter JavaDoc printWriter, String JavaDoc header) {
101         ExceptionFormatter.printTrace(this, printWriter, header);
102     }
103
104     // Return a single XaException without the "next" pointing to another SQLException.
105
// Because the "next" is a private field in java.sql.SQLException,
106
// we have to create a new XaException in order to break the chain with "next" as null.
107
XaException copyAsUnchainedXAException(LogWriter logWriter) {
108         XaException xae = new XaException(logWriter, this.getThrowable(), getMessage()); // client error
109
xae.errorCode = this.errorCode;
110         return xae;
111     }
112 }
113
114
115
116
Popular Tags