01: /*
02: Copyright (C) 2002-2007 MySQL AB
03:
04: This program is free software; you can redistribute it and/or modify
05: it under the terms of version 2 of the GNU General Public License as
06: published by the Free Software Foundation.
07:
08: There are special exceptions to the terms and conditions of the GPL
09: as it is applied to this software. View the full text of the
10: exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
11: software distribution.
12:
13: This program is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: GNU General Public License for more details.
17:
18: You should have received a copy of the GNU General Public License
19: along with this program; if not, write to the Free Software
20: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21:
22:
23:
24: */
25: package com.mysql.jdbc;
26:
27: import java.net.BindException;
28:
29: import java.sql.SQLException;
30:
31: /**
32: * An exception to represent communications errors with the database.
33: *
34: * Attempts to provide 'friendler' error messages to end-users, including last
35: * time a packet was sent to the database, what the client-timeout is set to,
36: * and whether the idle time has been exceeded.
37: *
38: * @author Mark Matthews
39: *
40: * @version $Id: CommunicationsException.java,v 1.1.2.1 2005/05/13 18:58:37
41: * mmatthews Exp $
42: */
43: public class CommunicationsException extends SQLException implements
44: StreamingNotifiable {
45:
46: private String exceptionMessage;
47:
48: private boolean streamingResultSetInPlay = false;
49:
50: public CommunicationsException(ConnectionImpl conn,
51: long lastPacketSentTimeMs, Exception underlyingException) {
52:
53: this .exceptionMessage = SQLError
54: .createLinkFailureMessageBasedOnHeuristics(conn,
55: lastPacketSentTimeMs, underlyingException,
56: this .streamingResultSetInPlay);
57: }
58:
59: /*
60: * (non-Javadoc)
61: *
62: * @see java.lang.Throwable#getMessage()
63: */
64: public String getMessage() {
65: return this .exceptionMessage;
66: }
67:
68: /*
69: * (non-Javadoc)
70: *
71: * @see java.sql.SQLException#getSQLState()
72: */
73: public String getSQLState() {
74: return SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE;
75: }
76:
77: /* (non-Javadoc)
78: * @see com.mysql.jdbc.StreamingNotifiable#setWasStreamingResults()
79: */
80: public void setWasStreamingResults() {
81: this .streamingResultSetInPlay = true;
82: }
83:
84: }
|