1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package javax.sql;
19
20import java.util.EventListener;
21
22/**
23 * An interface used to receive events generated by a {@link PooledConnection}.
24 * <p>
25 * This interface would typically be implemented by a component which manages a
26 * connection pool (a connection pool manager). A connection triggers an event
27 * to a {@code ConnectionEventListener} either when the application closes a
28 * connection it has been using or when a significant error occurs while the
29 * connection is being used.
30 * <p>
31 * The connection pool manager can return closed connections to the pool for
32 * later reuse. Connections experiencing an error should be discarded.
33 */
34public interface ConnectionEventListener extends EventListener {
35
36    /**
37     * Notifies the {@code ConnectionEventListener} that an application has
38     * called the {@code close} method on a pooled connection.
39     *
40     * @param theEvent
41     *            a {@code ConnectionEvent} containing details about the source
42     *            of the event.
43     */
44    public void connectionClosed(ConnectionEvent theEvent);
45
46    /**
47     * Notifies the {@code ConnectionEventListener} that an error has occurred
48     * on a {@code PooledConnection}. This notification is triggered <i>before</i> the
49     * {@code SQLException}, which is available through the event argument, is
50     * thrown.
51     *
52     * @param theEvent
53     *            a {@code ConnectionEvent} containing details about the source
54     *            of the event and the {@code SQLException} that has occurred.
55     */
56    public void connectionErrorOccurred(ConnectionEvent theEvent);
57}
58