001: /*
002:
003: Derby - Class org.apache.derby.client.am.XaException
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.client.am;
023:
024: public class XaException extends javax.transaction.xa.XAException
025: implements Diagnosable {
026: java.lang.Throwable throwable_ = null;
027:
028: //-----------------constructors-----------------------------------------------
029:
030: public XaException(LogWriter logWriter) {
031: super ();
032: if (logWriter != null) {
033: logWriter.traceDiagnosable(this );
034: }
035: }
036:
037: public XaException(LogWriter logWriter,
038: java.lang.Throwable throwable) {
039: super ();
040: throwable_ = throwable;
041: if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) && (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4))
042: || (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
043: initCause(throwable);
044: }
045: if (logWriter != null) {
046: logWriter.traceDiagnosable(this );
047: }
048: }
049:
050: public XaException(LogWriter logWriter, int errcode) {
051: super ();
052: errorCode = errcode;
053: if (logWriter != null) {
054: logWriter.traceDiagnosable(this );
055: }
056: }
057:
058: public XaException(LogWriter logWriter,
059: java.lang.Throwable throwable, int errcode) {
060: super ();
061: errorCode = errcode;
062: throwable_ = throwable;
063: if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) && (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4))
064: || (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
065: initCause(throwable);
066: }
067: if (logWriter != null) {
068: logWriter.traceDiagnosable(this );
069: }
070: }
071:
072: public XaException(LogWriter logWriter, String s) {
073: super (s);
074: if (logWriter != null) {
075: logWriter.traceDiagnosable(this );
076: }
077: }
078:
079: public XaException(LogWriter logWriter,
080: java.lang.Throwable throwable, String s) {
081: super (s);
082: throwable_ = throwable;
083: if (((org.apache.derby.client.am.Configuration.jreLevelMajor == 1) && (org.apache.derby.client.am.Configuration.jreLevelMinor >= 4))
084: || (org.apache.derby.client.am.Configuration.jreLevelMajor > 1)) { // jre 1.4 or above, init the cause
085: initCause(throwable);
086: }
087: if (logWriter != null) {
088: logWriter.traceDiagnosable(this );
089: }
090: }
091:
092: public Sqlca getSqlca() {
093: return null;
094: }
095:
096: public java.lang.Throwable getThrowable() {
097: return throwable_;
098: }
099:
100: public void printTrace(java.io.PrintWriter printWriter,
101: String header) {
102: ExceptionFormatter.printTrace(this , printWriter, header);
103: }
104:
105: // Return a single XaException without the "next" pointing to another SQLException.
106: // Because the "next" is a private field in java.sql.SQLException,
107: // we have to create a new XaException in order to break the chain with "next" as null.
108: XaException copyAsUnchainedXAException(LogWriter logWriter) {
109: XaException xae = new XaException(logWriter, this
110: .getThrowable(), getMessage()); // client error
111: xae.errorCode = this.errorCode;
112: return xae;
113: }
114: }
|