Package javax.sql

Examples of javax.sql.PooledConnection


    private Connection getConnectionNow() throws SQLException {
        if (isDisposed) {
            throw new IllegalStateException("Connection pool has been disposed.");
        }
        PooledConnection pc;
        if (!recycledConnections.isEmpty()) {
            pc = recycledConnections.remove(recycledConnections.size() - 1);
        } else {
            pc = dataSource.getPooledConnection();
        }
        Connection conn = pc.getConnection();
        activeConnections++;
        pc.addConnectionEventListener(this);
        return conn;
    }
View Full Code Here


    /**
     * INTERNAL
     */
    public void connectionClosed(ConnectionEvent event) {
        PooledConnection pc = (PooledConnection) event.getSource();
        pc.removeConnectionEventListener(this);
        recycleConnection(pc);
    }
View Full Code Here

     *
     * @throws SQLException
     */
    public Connection getConnection() throws SQLException {

        PooledConnection pooledConnection = null;

        synchronized (this) {
            if (!initialized) {
                if (initialSize > maxPoolSize) {
                    throw new SQLException("Initial size of " + initialSize
View Full Code Here

        }
    }

    private PooledConnection createNewConnection() throws SQLException {

        PooledConnection pooledConnection;

        // I have changed "size() + 1" to "size()".  I don't know why
        // we would want to report 1 more than the actual pool size,
        // so I am assuming that this is a coding error.  (The size
        // method does return the actual size of an array).  -blaine
        logInfo("Connection created since no connections available and "
                + "pool has space for more connections. Pool size: " + size());

        pooledConnection = this.connectionPoolDataSource.getPooledConnection();

        pooledConnection.addConnectionEventListener(this);

        return pooledConnection;
    }
View Full Code Here

        long     sessionTimeoutMillis = ((long) sessionTimeout) * 1000L;
        Iterator iterator             = this.connectionsInUse.iterator();
        List     abandonedConnections = new ArrayList();

        while (iterator.hasNext()) {
            PooledConnection connectionInUse =
                (PooledConnection) iterator.next();
            SessionConnectionWrapper sessionWrapper =
                (SessionConnectionWrapper) this.sessionConnectionWrappers.get(
                    connectionInUse);

View Full Code Here

        return this.maxPoolSize > size();
    }

    public synchronized void connectionClosed(ConnectionEvent event) {

        PooledConnection connection = (PooledConnection) event.getSource();

        this.connectionsInUse.remove(connection);
        this.sessionConnectionWrappers.remove(connection);

        if (!this.isPoolClosed) {
View Full Code Here

     * A new connection will be created to replace the invalid connection, when the next client
     * calls getConnection().
     */
    public synchronized void connectionErrorOccurred(ConnectionEvent event) {

        PooledConnection connection = (PooledConnection) event.getSource();

        connection.removeConnectionEventListener(this);
        this.connectionsInUse.remove(connection);
        this.sessionConnectionWrappers.remove(connection);
        logInfo(
            "Fatal exception occurred on pooled connection. Connection is removed from pool: ");
        logInfo(event.getSQLException());
View Full Code Here

    public synchronized void close() {

        this.isPoolClosed = true;

        while (this.connectionsInactive.size() > 0) {
            PooledConnection connection = dequeueFirstIfAny();

            if (connection != null) {
                closePhysically(
                    connection,
                    "closing inactive connection when connection pool was closed.");
View Full Code Here

        close();

        Iterator iterator = this.connectionsInUse.iterator();

        while (iterator.hasNext()) {
            PooledConnection connection = (PooledConnection) iterator.next();
            SessionConnectionWrapper sessionWrapper =
                (SessionConnectionWrapper) this.sessionConnectionWrappers.get(
                    connection);

            closeSessionWrapper(
View Full Code Here

     */
    public synchronized Object makeObject(Object key) throws Exception {
        Object obj = null;
        UserPassKey upkey = (UserPassKey)key;

        PooledConnection pc = null;
        String username = upkey.getUsername();
        String password = upkey.getPassword();
        if (username == null) {
            pc = _cpds.getPooledConnection();
        } else {
            pc = _cpds.getPooledConnection(username, password);
        }

        if (pc == null) {
            throw new IllegalStateException("Connection pool data source returned null from getPooledConnection");
        }

        // should we add this object as a listener or the pool.
        // consider the validateObject method in decision
        pc.addConnectionEventListener(this);
        obj = new PooledConnectionAndInfo(pc, username, password);
        pcMap.put(pc, obj);

        return obj;
    }
View Full Code Here

TOP

Related Classes of javax.sql.PooledConnection

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.