Package javax.sql

Examples of javax.sql.PooledConnection


        cpds.setPortNumber(TestConfiguration.getCurrent().getPort());
       
        cpds.setDatabaseName(dbName);
        cpds.setConnectionAttributes(
                retrieveMessageTextProperty + "=false");
        PooledConnection cpConn = cpds.getPooledConnection();
        assertMessageText(cpConn.getConnection(), "false");
        cpConn.close();
        cpds.setConnectionAttributes(
                retrieveMessageTextProperty + "=true");
        cpConn = cpds.getPooledConnection();
        assertMessageText(cpConn.getConnection(), "true");
        cpds.setConnectionAttributes(null);
        cpConn.close();

        // now with XADataSource
        ClientXADataSource xads = new ClientXADataSource();
        //XADataSource - retrieveMessageTextProperty
        xads.setPortNumber(TestConfiguration.getCurrent().getPort());
View Full Code Here


     */
    public void testConnectionLeakInDatabaseMetaData()
            throws SQLException {
        ConnectionPoolDataSource cpDs =
                J2EEDataSource.getConnectionPoolDataSource();
        PooledConnection pc = cpDs.getPooledConnection();
        // Get first logical connection and a meta data object.
        Connection con1 = pc.getConnection();
        DatabaseMetaData dmd1 = con1.getMetaData();
        assertSame(con1, dmd1.getConnection());
        con1.close();
        // Get second logical connection and a meta data object.
        Connection con2 = pc.getConnection();
        DatabaseMetaData dmd2 = con2.getMetaData();
        // The first meta data object should not return a reference to the
        // second logical connection.
        assertSame(con2, dmd2.getConnection());
        try {
            dmd1.getConnection();
            fail("Should have thrown no current connection exception");
        } catch (SQLException sqle) {
            assertSQLState("08003", sqle);
        }
        con2.close();
        pc.close();
        try {
            dmd2.getConnection();
            fail("Should have thrown no current connection exception");
        } catch (SQLException sqle) {
            assertSQLState("08003", sqle);
View Full Code Here

     * See Jira issue DERBY-3799.
     */
    public void testDerby3799() throws SQLException {
        ConnectionPoolDataSource cpDs =
                J2EEDataSource.getConnectionPoolDataSource();
        PooledConnection pc = cpDs.getPooledConnection();
        // Get first logical connection.
        Connection con1 = pc.getConnection();
        Statement stmt = con1.createStatement();
        ResultSet rs = stmt.executeQuery("select dClob from derby3799");
        assertTrue(rs.next());
        rs.getString(1);
        rs.close();
        con1.close();
        // Get second logical connection.
        Connection con2 = pc.getConnection();
        stmt = con2.createStatement();
        rs = stmt.executeQuery("select dClob from derby3799");
        assertTrue(rs.next());
        rs.getString(1); // NPE happened here.
        con2.close();
View Full Code Here

     *
     * @throws SQLException
     */
    public void timeoutTestDerby1144PooledDS() throws SQLException {
   
        PooledConnection pc1 = null;

        // Test holdability  
        ConnectionPoolDataSource ds =
            J2EEDataSource.getConnectionPoolDataSource();
        pc1 = ds.getPooledConnection();
        assertPooledConnHoldability("PooledConnection", pc1);
        pc1.close();
       
        // Test autocommit
        pc1 = ds.getPooledConnection();
        assertPooledConnAutoCommit("PooledConnection", pc1);
        pc1.close();
       
        // Test pooled connection isolation
        pc1 = ds.getPooledConnection();
        assertPooledConnIso("PooledConnection" , pc1);  
        pc1.close();
    }
View Full Code Here

        //  First get a bunch of pooled connections
        //  and make sure they're all unique
        Hashtable pooledConns = new Hashtable();
        for ( int i = 0 ; i < numConnections ; i++ )
        {
            PooledConnection pc = pds.getPooledConnection();
            assertStringFormat(pc);
            String str = pc.toString();
            // Pooled connection toString should be unique
            assertNull( pooledConns.get(str));
            pooledConns.put(str, pc);
        }

        // Now check that connections from each of these
        // pooled connections have different string values
        Iterator it = pooledConns.values().iterator();
        clearConnections();
        while ( it.hasNext() )
        {
            PooledConnection pc = (PooledConnection)it.next();
            Connection conn = pc.getConnection();
            assertToString(conn);
        }
        clearConnections();

        // Now clear out the pooled connections
        it = pooledConns.values().iterator();
        while ( it.hasNext() )
        {
            PooledConnection pc = (PooledConnection)it.next();
            pc.close();
        }
        pooledConns.clear();
    }
View Full Code Here

                "SecurityMechanism", secmec);
              
        // simulate case when connection will be re-used by getting
        // a connection, closing it and then the next call to
        // getConnection will re-use the previous connection. 
        PooledConnection pc = cpds.getPooledConnection();
        Connection conn = pc.getConnection();
        conn.close();
        conn = pc.getConnection();
        assertConnectionOK(conn);
        pc.close();
        conn.close();
    }
View Full Code Here

    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

  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.incrementAndGet();
    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

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.