Package javax.sql

Examples of javax.sql.ConnectionEventListener


        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();
                    if (exception == null) {
                        l.connectionClosed(event);
                    } else {
                        l.connectionErrorOccurred(event);
                    }
                }
            } finally {
                eventIterators--;
            }
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

        userConnection = null;

        release();

        for (int i = 0; i < listeners.size(); i++) {
            ConnectionEventListener connectionEventListener =
                (ConnectionEventListener) listeners.get(i);

            connectionEventListener.connectionClosed(event);
        }
    }
View Full Code Here

        ConnectionEvent event = new ConnectionEvent(this, e);

        release();

        for (int i = 0; i < listeners.size(); i++) {
            ConnectionEventListener connectionEventListener =
                (ConnectionEventListener) listeners.get(i);

            connectionEventListener.connectionErrorOccurred(event);
        }
    }
View Full Code Here

    ConnectionEvent connectionevent = new ConnectionEvent(this,
        sqlException);

    while (iterator.hasNext()) {

      ConnectionEventListener connectioneventlistener = (ConnectionEventListener) ((Map.Entry)iterator
          .next()).getValue();

      if (eventType == CONNECTION_CLOSED_EVENT) {
        connectioneventlistener.connectionClosed(connectionevent);
      } else if (eventType == CONNECTION_ERROR_EVENT) {
        connectioneventlistener
            .connectionErrorOccurred(connectionevent);
      }
    }
  }
View Full Code Here

  /**
   * Tests fix for BUG#7136 ... Statement.getConnection() returning physical
   * connection instead of logical connection.
   */
  public void testBug7136() {
    final ConnectionEventListener conListener = new ConnectionListener();
    PooledConnection pc = null;
    this.closeEventCount = 0;

    try {
      pc = this.cpds.getPooledConnection();
View Full Code Here

  /**
   * Test the nb of closeEvents generated when a Connection is reclaimed. No
   * event should be generated in that case.
   */
  public void testConnectionReclaim() {
    final ConnectionEventListener conListener = new ConnectionListener();
    PooledConnection pc = null;
    final int NB_TESTS = 5;

    try {
      pc = this.cpds.getPooledConnection();
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.