Package javax.sql

Examples of javax.sql.ConnectionEventListener


   */
  protected synchronized void notifyListener(SQLException e){
    if(listeners != null && !listeners.isEmpty()){
      Iterator iter = listeners.iterator();
      while(iter.hasNext()){
        ConnectionEventListener listener = (ConnectionEventListener)iter.next();
        if(e == null){
          //no exception
          listener.connectionClosed(new ConnectionEvent(this));
        }else{
          //exception occurred
          listener.connectionErrorOccurred(new ConnectionEvent(this, e))
        }
      }
    } 
  }
View Full Code Here


        }

        int traceId = ((JdbcXAConnection) xaConn).getTraceId();
        assertTrue(xaConn.toString().startsWith("xads" + traceId + ": conn"));

        xaConn.addConnectionEventListener(new ConnectionEventListener() {
            public void connectionClosed(ConnectionEvent event) {
                // nothing to do
            }

            public void connectionErrorOccurred(ConnectionEvent event) {
View Full Code Here

        ConnectionImpl c = Mockito.mock(ConnectionImpl.class);
        Mockito.doThrow(new SQLException(new InvalidSessionException())).when(c).commit();
        return c;
      }
    });
    ConnectionEventListener cel = Mockito.mock(ConnectionEventListener.class);
    xaConn.addConnectionEventListener(cel);
    Connection c = xaConn.getConnection();
    try {
      c.commit();
    } catch (SQLException e) {
View Full Code Here

        debugCode("closedHandle();");
        ConnectionEvent event = new ConnectionEvent(this);
        // go backward so that a listener can remove itself
        // (otherwise we need to clone the list)
        for (int i = listeners.size() - 1; i >= 0; i--) {
            ConnectionEventListener listener = listeners.get(i);
            listener.connectionClosed(event);
        }
        handleConn = null;
    }
View Full Code Here

  protected void notifyClose() {
      if (listeners.size()>0) {
        Iterator<ConnectionEventListener> oIter = listeners.iterator();
        while (oIter.hasNext()) {
          ConnectionEventListener oCevl = oIter.next();
          oCevl.connectionClosed(new ConnectionEvent(this));
        } // wend
      } // fi       
  } // notifyClose
View Full Code Here

     * @param ex the given exception
     */
    public void notifyError(final IManagedConnection proxy, final SQLException ex) {
        // Notify event to listeners
        for (int i = 0; i < eventListeners.size(); i++) {
            ConnectionEventListener l = eventListeners.elementAt(i);
            l.connectionErrorOccurred(new ConnectionEvent(proxy, ex));
        }
    }
View Full Code Here

        ConnectionEvent event = new ConnectionEvent(this.pooledConnection, e);

        for (Iterator iterator = connectionListeners.iterator();
                iterator.hasNext(); ) {
            ConnectionEventListener connectionEventListener =
                (ConnectionEventListener) iterator.next();

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

        ConnectionEvent connectionEvent =
            new ConnectionEvent(this.pooledConnection);

        for (Iterator iterator = connectionListeners.iterator();
                iterator.hasNext(); ) {
            ConnectionEventListener connectionListener =
                (ConnectionEventListener) iterator.next();

            connectionListener.connectionClosed(connectionEvent);
        }
    }
View Full Code Here

  void closeEvent(Connection conn)
  {
    ConnectionEvent event = new ConnectionEvent(this);
   
    for (int i = 0; i < _listeners.size(); i++) {
      ConnectionEventListener listener = _listeners.get(i);

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

        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

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.