KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mchange > v2 > c3p0 > UnifiedConnectionTester


1 /*
2  * Distributed as part of c3p0 v.0.9.1
3  *
4  * Copyright (C) 2005 Machinery For Change, Inc.
5  *
6  * Author: Steve Waldman <swaldman@mchange.com>
7  *
8  * This library is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License version 2.1, as
10  * published by the Free Software Foundation.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this software; see the file LICENSE. If not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */

22
23
24 package com.mchange.v2.c3p0;
25
26 import java.sql.Connection JavaDoc;
27
28 /**
29  * <p>Having expanded the once-simple ConnectionTester interface to support both
30  * user-specified queries and return of root cause Exceptions (via an out-param),
31  * this interface has grown unnecessarily complex.</p>
32  *
33  * <p>If you wish to implement a custom Connection tester, here is the simple
34  * way to do it</p>
35  *
36  * <ol>
37  * <li>Extend {@link com.mchange.v2.c3p0.AbstractConnectionTester}</li>
38  * <li>Override only the two abstract methods</li>
39  * <ul>
40  * <li><tt>public int activeCheckConnection(Connection c, String preferredTestQuery, Throwable[] rootCauseOutParamHolder)</tt></li>
41  * <li><tt>public int statusOnException(Connection c, Throwable t, String preferredTestQuery, Throwable[] rootCauseOutParamHolder)</tt></li>
42  * </ul>
43  * <li>Take care to ensure that your methods are defined to allow <tt>preferredTestQuery</tt> and
44  * <tt>rootCauseOutParamHolder</tt> to be <tt>null</tt>.</li>
45  * </ol>
46  *
47  * <p>Parameter <tt>rootCauseOutParamHolder</tt> is an optional parameter, which if supplied, will be a Throwable array whose size
48  * it at least one. If a Connection test fails because of some Exception, the Connection tester may set this Exception as the
49  * zero-th element of the array to provide information about why and how the test failed.</p>
50  */

51 public interface UnifiedConnectionTester extends FullQueryConnectionTester
52 {
53     public final static int CONNECTION_IS_OKAY = ConnectionTester.CONNECTION_IS_OKAY;
54     public final static int CONNECTION_IS_INVALID = ConnectionTester.CONNECTION_IS_INVALID;
55     public final static int DATABASE_IS_INVALID = ConnectionTester.DATABASE_IS_INVALID;
56     
57     public int activeCheckConnection(Connection JavaDoc c);
58     public int activeCheckConnection(Connection JavaDoc c, Throwable JavaDoc[] rootCauseOutParamHolder);
59     public int activeCheckConnection(Connection JavaDoc c, String JavaDoc preferredTestQuery);
60     public int activeCheckConnection(Connection JavaDoc c, String JavaDoc preferredTestQuery, Throwable JavaDoc[] rootCauseOutParamHolder);
61
62     public int statusOnException(Connection JavaDoc c, Throwable JavaDoc t);
63     public int statusOnException(Connection JavaDoc c, Throwable JavaDoc t, Throwable JavaDoc[] rootCauseOutParamHolder);
64     public int statusOnException(Connection JavaDoc c, Throwable JavaDoc t, String JavaDoc preferredTestQuery);
65     public int statusOnException(Connection JavaDoc c, Throwable JavaDoc t, String JavaDoc preferredTestQuery, Throwable JavaDoc[] rootCauseOutParamHolder);
66
67     public boolean equals(Object JavaDoc o);
68     public int hashCode();
69 }
70
Popular Tags