Package javax.sql

Examples of javax.sql.ConnectionEvent


                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    try {
                        String name = method.getName();
                        if ("close".equals(name)) {
                            ConnectionEvent event = new ConnectionEvent(SQLitePooledConnection.this);

                            for (int i = listeners.size() - 1; i >= 0; i--) {
                                listeners.get(i).connectionClosed(event);
                            }

                            if (!physicalConn.getAutoCommit()) {
                                physicalConn.rollback();
                            }
                            physicalConn.setAutoCommit(true);
                            isClosed = true;

                            return null; // don't close physical connection
                        }
                        else if ("isClosed".equals(name)) {
                            if (!isClosed)
                                isClosed = ((Boolean)method.invoke(physicalConn, args)).booleanValue();

                            return isClosed;
                        }

                        if (isClosed) {
                            throw new SQLException ("Connection is closed");
                        }

                        return method.invoke(physicalConn, args);
                    }
                    catch (SQLException e){
                        if ("database connection closed".equals(e.getMessage())) {
                            ConnectionEvent event = new ConnectionEvent(SQLitePooledConnection.this, e);

                            for (int i = listeners.size() - 1; i >= 0; i--) {
                                listeners.get(i).connectionErrorOccurred(event);
                            }
                        }
View Full Code Here


    /**
     * INTERNAL
     */
    void closedHandle() {
        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);
View Full Code Here

                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    try {
                        String name = method.getName();
                        if ("close".equals(name)) {
                            ConnectionEvent event = new ConnectionEvent(SQLitePooledConnection.this);

                            for (int i = listeners.size() - 1; i >= 0; i--) {
                                listeners.get(i).connectionClosed(event);
                            }

                            if (!physicalConn.getAutoCommit()) {
                                physicalConn.rollback();
                            }
                            physicalConn.setAutoCommit(true);
                            isClosed = true;

                            return null; // don't close physical connection
                        }
                        else if ("isClosed".equals(name)) {
                            if (!isClosed)
                                isClosed = ((Boolean)method.invoke(physicalConn, args)).booleanValue();

                            return isClosed;
                        }

                        if (isClosed) {
                            throw new SQLException ("Connection is closed");
                        }

                        return method.invoke(physicalConn, args);
                    }
                    catch (SQLException e){
                        if ("database connection closed".equals(e.getMessage())) {
                            ConnectionEvent event = new ConnectionEvent(SQLitePooledConnection.this, e);

                            for (int i = listeners.size() - 1; i >= 0; i--) {
                                listeners.get(i).connectionErrorOccurred(event);
                            }
                        }
View Full Code Here

      return;

    // tell my listeners an exception is about to be thrown
    if (eventListener != null && eventListener.size() > 0)
    {
      ConnectionEvent errorEvent = new ConnectionEvent(this, exception);

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

    //the newly assigned currentConnectionHandle null, resulting in an NPE.
    currentConnectionHandle = null;
    // tell my listeners I am closed
    if (eventListener != null && eventListener.size() > 0)
    {
      ConnectionEvent closeEvent = new ConnectionEvent(this);

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

        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

        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

    /**
     * sends a connectionClosed event.
     */
    void notifyListeners() {
        ConnectionEvent event = new ConnectionEvent(this);
        Object[] listeners = eventListeners.toArray();
        for (Object listener : listeners) {
            ((ConnectionEventListener) listener).connectionClosed(event);
        }
    }
View Full Code Here

    /**
     * sends a connectionClosed event.
     */
    void notifyListeners() {
        ConnectionEvent event = new ConnectionEvent(this);
        Object[] listeners = eventListeners.toArray();
        for (Object listener : listeners) {
            ((ConnectionEventListener) listener).connectionClosed(event);
        }
    }
View Full Code Here

    public void removeStatementEventListener(StatementEventListener listener) {
        throw new UnsupportedOperationException();
    }

    protected void notifyConnectionClosed() {
        ConnectionEvent event = new ConnectionEvent(this);
        List<ConnectionEventListener> copy = new ArrayList<>(
                listeners);
        for (ConnectionEventListener listener : copy) {
            listener.connectionClosed(event);
        }
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.