Source code: com/mysql/jdbc/jdbc2/optional/WrapperBase.java
1 /*
2 Copyright (C) 2002-2004 MySQL AB
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of version 2 of the GNU General Public License as
6 published by the Free Software Foundation.
7
8
9 There are special exceptions to the terms and conditions of the GPL
10 as it is applied to this software. View the full text of the
11 exception exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
12 software distribution.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 */
24 package com.mysql.jdbc.jdbc2.optional;
25
26 import java.sql.SQLException;
27
28 import com.mysql.jdbc.SQLError;
29
30 /**
31 * Base class for all wrapped instances created by LogicalHandle
32 *
33 * @author Mark matthews
34 *
35 * @version $Id: WrapperBase.java,v 1.1.2.3 2004/08/09 22:15:12 mmatthew Exp $
36 */
37 abstract class WrapperBase {
38 protected MysqlPooledConnection pooledConnection;
39
40 /**
41 * Fires connection error event if required, before re-throwing exception
42 *
43 * @param sqlEx the SQLException that has ocurred
44 * @throws SQLException (rethrown)
45 */
46 protected void checkAndFireConnectionError(SQLException sqlEx) throws SQLException {
47 if (this.pooledConnection != null) {
48 if (SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE.equals(sqlEx.getSQLState())) {
49 this.pooledConnection.callListener(MysqlPooledConnection.CONNECTION_ERROR_EVENT, sqlEx);
50 }
51 }
52
53 throw sqlEx;
54 }
55 }