Package javax.sql

Examples of javax.sql.ConnectionEventListener


        // Null out the reference to the logical connection that is currently
        // being closed.
        this.logicalConnection_ = null;

        for (Iterator e = listeners_.iterator(); e.hasNext();) {
            ConnectionEventListener listener =
                    (ConnectionEventListener)e.next();
            ConnectionEvent event = new ConnectionEvent(this);
            listener.connectionClosed(event);
        }
    }
View Full Code Here


    if (exception.getErrorCode() < ExceptionSeverity.SESSION_SEVERITY)
      return;

        synchronized (this) {
            for (Iterator e = listeners_.iterator(); e.hasNext();) {
                ConnectionEventListener listener =
                        (ConnectionEventListener)e.next();
                SQLException sqle = exception.getSQLException();
                ConnectionEvent event = new ConnectionEvent(this, sqle);
                listener.connectionErrorOccurred(event);
            }
        }
    }
View Full Code Here

      ConnectionEvent errorEvent = new ConnectionEvent(this, exception);

      for (Enumeration e = eventListener.elements();
         e.hasMoreElements(); )
      {
        ConnectionEventListener l =
          (ConnectionEventListener)e.nextElement();
        l.connectionErrorOccurred(errorEvent);
      }
    }
  }
View Full Code Here

      ConnectionEvent closeEvent = new ConnectionEvent(this);

      for (Enumeration e = eventListener.elements();
         e.hasMoreElements(); )
      {
        ConnectionEventListener l =
          (ConnectionEventListener)e.nextElement();
        l.connectionClosed(closeEvent);
      }
    }

    return false;
  }
View Full Code Here

      ConnectionEvent errorEvent = new ConnectionEvent(this, exception);

      for (Enumeration e = eventListener.elements();
         e.hasMoreElements(); )
      {
        ConnectionEventListener l =
          (ConnectionEventListener)e.nextElement();
        l.connectionErrorOccurred(errorEvent);
      }
    }
  }
View Full Code Here

      ConnectionEvent closeEvent = new ConnectionEvent(this);

      for (Enumeration e = eventListener.elements();
         e.hasMoreElements(); )
      {
        ConnectionEventListener l =
          (ConnectionEventListener)e.nextElement();
        l.connectionClosed(closeEvent);
      }
    }
  }
View Full Code Here

     * ConnectionEventListener.connectionClosed() is called.
     */
    private void subtestPooledReuseOnClose(final PooledConnection pc) throws SQLException
    {
      final Connection[] newConn = new Connection[1];
      pc.addConnectionEventListener(new ConnectionEventListener() {

        /**
         * Mimic a pool handler that returns the PooledConnection
         * to the pool and then reallocates it to a new logical connection.
         */
 
View Full Code Here

     * Tests that a pooled connection can successfully be closed
     * during the processing of its close event by its listener.
     */
    private void subtestPooledCloseOnClose(final PooledConnection pc) throws SQLException
    {
        pc.addConnectionEventListener(new ConnectionEventListener() {

            /**
             * Mimic a pool handler that closes the PooledConnection
             * (say it no longer needs it, pool size being reduced)
             */
 
View Full Code Here

     */
    private void subtestPooledRemoveListenerOnClose(final PooledConnection pc) throws SQLException
    {
       
        final int[] count1 = new int[1];
        pc.addConnectionEventListener(new ConnectionEventListener() {

            /**
             * Mimic a pool handler that removes the listener during
             * a logical close.
             */
            public void connectionClosed(ConnectionEvent event) {
                PooledConnection pce = (PooledConnection) event.getSource();
                assertSame(pc, pce);
                count1[0]++;
                pce.removeConnectionEventListener(this);
            }

            public void connectionErrorOccurred(ConnectionEvent event) {
            }
           
        });
       
        // and have another listener to ensure removing one leaves
        // the other working and intact.
        final int[] count2 = new int[1];
        pc.addConnectionEventListener(new ConnectionEventListener() {

            /**
             * Mimic a pool handler that closes the PooledConnection
             * (say it no longer needs it, pool size being reduced)
             */
 
View Full Code Here

        // has been triggered, number of times added listeners have been
        // triggered }.
        final int[] count = new int[2];

        // Register the main listener
        pc.addConnectionEventListener(new ConnectionEventListener() {

            public void connectionClosed(ConnectionEvent event) {
                assertSame(pc, event.getSource());
                count[0]++;
                // Register a new listener
                pc.addConnectionEventListener(new ConnectionEventListener() {
                    public void connectionClosed(ConnectionEvent e) {
                        assertSame(pc, e.getSource());
                        count[1]++;
                    }
                    public void connectionErrorOccurred(ConnectionEvent e) {
View Full Code Here

TOP

Related Classes of javax.sql.ConnectionEventListener

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.