Package javax.sql

Examples of javax.sql.ConnectionEvent


     * @param exception the exception that caused the event, or {@code null} if
     * it is a close event
     */
    private void fireConnectionEventListeners(SQLException exception) {
        if (eventListener != null && !eventListener.isEmpty()) {
            ConnectionEvent event = new ConnectionEvent(this, exception);
            eventIterators++;
            try {
                for (Iterator it = eventListener.iterator(); it.hasNext();) {
                    ConnectionEventListener l =
                            (ConnectionEventListener) it.next();
View Full Code Here


      return;
    }

    Enumeration enumeration = this.eventListeners.keys();
    ConnectionEvent connectionevent = new ConnectionEvent(this,
        sqlException);

    while (enumeration.hasMoreElements()) {

      ConnectionEventListener connectioneventlistener = (ConnectionEventListener) enumeration
View Full Code Here

public class ConnectionEventTest extends TestCase {

    public void testConstructorConnection() {
        try {
            new ConnectionEvent(null);
            fail("illegal argument exception expected");
        } catch (IllegalArgumentException e) {
        }

        Impl_PooledConnection ipc = new Impl_PooledConnection();
        ConnectionEvent ce = new ConnectionEvent(ipc);
        assertSame(ipc, ce.getSource());
        assertNull(ce.getSQLException());
    }
View Full Code Here

        assertNull(ce.getSQLException());
    }

    public void testConstructorConnectionSQLException() {
        try {
            new ConnectionEvent(null, null);
            fail("illegal argument exception expected");
        } catch (IllegalArgumentException e) {
        }

        Impl_PooledConnection ipc = new Impl_PooledConnection();
        ConnectionEvent ce = new ConnectionEvent(ipc, null);
        assertSame(ipc, ce.getSource());
        assertNull(ce.getSQLException());

        SQLException e = new SQLException();
        ce = new ConnectionEvent(ipc, e);
        assertSame(ipc, ce.getSource());
        assertSame(e, ce.getSQLException());
    }
View Full Code Here

     * @tests serialization/deserialization compatibility.
     */
    public void testSerializationSelf() throws Exception {
        Impl_PooledConnection ipc = new Impl_PooledConnection();
        SQLException e = new SQLException();
        ConnectionEvent ce = new ConnectionEvent(ipc, e);
        SerializationTest.verifySelf(ce, CONNECTIONEVENT_COMPARATOR);
    }
View Full Code Here

        SQLException sqlException = new SQLException("reason", "SQLState",
                vendorCode);

        sqlException.setNextException(nextSQLException);

        ConnectionEvent ce = new ConnectionEvent(ipc, sqlException);

        SerializationTest.verifyGolden(this, ce, CONNECTIONEVENT_COMPARATOR);
    }
View Full Code Here

    /**
     * sends a connectionClosed event.
     */
    void notifyListeners() {
        ConnectionEvent event = new ConnectionEvent(this);
        Iterator i = eventListeners.iterator();
        while (i.hasNext()) {
            ((ConnectionEventListener) i.next()).connectionClosed(event);
        }
    }
View Full Code Here

        synchronized (connectionEventListeners) {
            if (connectionEventListeners.size() == 0)
                return;

            ConnectionEvent closedEvent = new ConnectionEvent(this, exception);
            for (final ConnectionEventListener nextListener : connectionEventListeners) {
                nextListener.connectionErrorOccurred(closedEvent);
            }
        }
    }
View Full Code Here

    protected void connectionClosedNotification() {
        synchronized (connectionEventListeners) {
            if (connectionEventListeners.size() == 0)
                return;

            ConnectionEvent closedEvent = new ConnectionEvent(this);

            for (final ConnectionEventListener nextListener : connectionEventListeners) {
                nextListener.connectionClosed(closedEvent);
            }
        }
View Full Code Here

        if (t instanceof SQLException) {
            SQLException sqlEx = (SQLException) t;

            // broadcastConnectionError
            ConnectionEvent event = new ConnectionEvent(pooledConnection, sqlEx);
            for (ConnectionEventListener eventListener : holder.getConnectionEventListeners()) {
                eventListener.connectionErrorOccurred(event);
            }

            // exceptionSorter.isExceptionFatal
View Full Code Here

TOP

Related Classes of javax.sql.ConnectionEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.