1 | /* |
---|
2 | Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
---|
3 | |
---|
4 | |
---|
5 | The MySQL Connector/J is licensed under the terms of the GPLv2 |
---|
6 | <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors. |
---|
7 | There are special exceptions to the terms and conditions of the GPLv2 as it is applied to |
---|
8 | this software, see the FLOSS License Exception |
---|
9 | <http://www.mysql.com/about/legal/licensing/foss-exception.html>. |
---|
10 | |
---|
11 | This program is free software; you can redistribute it and/or modify it under the terms |
---|
12 | of the GNU General Public License as published by the Free Software Foundation; version 2 |
---|
13 | of the License. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
---|
16 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
17 | See the GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License along with this |
---|
20 | program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth |
---|
21 | Floor, Boston, MA 02110-1301 USA |
---|
22 | |
---|
23 | */ |
---|
24 | |
---|
25 | package com.mysql.jdbc.jdbc2.optional; |
---|
26 | |
---|
27 | import javax.transaction.xa.XAException; |
---|
28 | |
---|
29 | /** |
---|
30 | * The stock XAException class isn't too friendly (i.e. no |
---|
31 | * error messages), so we extend it a bit. |
---|
32 | */ |
---|
33 | class MysqlXAException extends XAException { |
---|
34 | private static final long serialVersionUID = -9075817535836563004L; |
---|
35 | |
---|
36 | private String message; |
---|
37 | protected String xidAsString; |
---|
38 | |
---|
39 | public MysqlXAException(int errorCode, String message, String xidAsString) { |
---|
40 | super(errorCode); |
---|
41 | this.message = message; |
---|
42 | this.xidAsString = xidAsString; |
---|
43 | } |
---|
44 | |
---|
45 | public MysqlXAException(String message, String xidAsString) { |
---|
46 | super(); |
---|
47 | |
---|
48 | this.message = message; |
---|
49 | this.xidAsString = xidAsString; |
---|
50 | } |
---|
51 | |
---|
52 | public String getMessage() { |
---|
53 | String superMessage = super.getMessage(); |
---|
54 | StringBuffer returnedMessage = new StringBuffer(); |
---|
55 | |
---|
56 | if (superMessage != null) { |
---|
57 | returnedMessage.append(superMessage); |
---|
58 | returnedMessage.append(":"); |
---|
59 | } |
---|
60 | |
---|
61 | if (this.message != null) { |
---|
62 | returnedMessage.append(this.message); |
---|
63 | } |
---|
64 | |
---|
65 | return returnedMessage.toString(); |
---|
66 | } |
---|
67 | } |
---|