Package javax.sql

Examples of javax.sql.ConnectionPoolDataSource


    public void testClientTraceFileDSConnectionAttribute() throws SQLException
    {
        String traceFile;

        // with ConnectionPoolDataSource
        ConnectionPoolDataSource cpds = J2EEDataSource.getConnectionPoolDataSource();

        traceFile = "trace3.out";
        JDBCDataSource.setBeanProperty(cpds, "connectionAttributes",
            "traceFile="+traceFile);
        // DERBY-2468 - trace3.out does not get created
View Full Code Here


     *
     * @throws SQLException if something goes wrong
     */
    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();
View Full Code Here

     * connection. The problem was that the LOB stored procedure objects on the
     * server side were closed and not reprepared.
     * 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());
View Full Code Here

    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

     * @throws Exception
     */
    private void assertSecMecWithConnPoolingOK(
        String user, String password, Short secmec) throws Exception
    {    
        ConnectionPoolDataSource cpds = getCPDS(user,password);
       
        // call setSecurityMechanism with secmec.
        JDBCDataSource.setBeanProperty(cpds,
                "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();
View Full Code Here

            attrs.put("user", user);
        if (password != null)
            attrs.put("password", password);

        attrs = addRequiredAttributes(attrs);
        ConnectionPoolDataSource cpds =
            J2EEDataSource.getConnectionPoolDataSource();
        for (Iterator i = attrs.keySet().iterator(); i.hasNext(); )
        {
            String property = (String) i.next();
            Object value = attrs.get(property);
View Full Code Here

    protected ConnectionPoolDataSource
        testCPDS(String username, String password)
        throws javax.naming.NamingException, SQLException {
        // The source of physical db connections
        ConnectionPoolDataSource cpds = this.dataSource;
        if (cpds == null) {           
            Context ctx = null;
            if (jndiEnvironment == null) {
                ctx = new InitialContext();               
            } else {
                ctx = new InitialContext(jndiEnvironment);
            }
            Object ds = ctx.lookup(dataSourceName);
            if (ds instanceof ConnectionPoolDataSource) {
                cpds = (ConnectionPoolDataSource) ds;
            } else {
                throw new SQLException("Illegal configuration: "
                    + "DataSource " + dataSourceName
                    + " (" + ds.getClass().getName() + ")"
                    + " doesn't implement javax.sql.ConnectionPoolDataSource");
            }
        }
       
        // try to get a connection with the supplied username/password
        PooledConnection conn = null;
        try {
            if (username != null) {
                conn = cpds.getPooledConnection(username, password);
            }
            else {
                conn = cpds.getPooledConnection();
            }
            if (conn == null) {
                throw new SQLException(
                    "Cannot connect using the supplied username/password");
            }
View Full Code Here

         throws javax.naming.NamingException
    {
        String key = getKey(username);
        if (!pools.containsKey(key))
        {
            ConnectionPoolDataSource cpds = this.cpds;
            if (cpds == null)
            {
                Context ctx = null;
                if (jndiEnvironment == null)
                {
View Full Code Here

         *
         * @return a <code>Connection</code> value
         * @exception SQLException if an error occurs
         */
        protected Connection newConnection_() throws SQLException {
            ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();
            for (Iterator it = dsProps.entrySet().iterator(); it.hasNext(); ) {
                Map.Entry e = (Map.Entry) it.next();
                J2EEDataSource.setBeanProperty(
                    ds, (String) e.getKey(), e.getValue());
            }
            PooledConnection pc =
                ds.getPooledConnection();
            return pc.getConnection();
        }
View Full Code Here

     * Test pooled connetion for chinese database name, user and password.
     * @throws SQLException
     */
    public void testCPDSConnect() throws SQLException {
        // Test chinese database name.
        ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();
        J2EEDataSource.setBeanProperty(ds, "databaseName", "\u4e10");
        J2EEDataSource.setBeanProperty(ds, "createDatabase", "create");       
        try {
            PooledConnection poolConn = ds.getPooledConnection();
            Connection conn = poolConn.getConnection();
            conn.close();
        } catch (SQLException se ) {
            if (usingEmbedded())
                throw se;
            else
                assertSQLState("22005",se);
        }  
        // Chinese user
        try {
            J2EEDataSource.setBeanProperty(ds, "user", "\u4e10");
            PooledConnection poolConn = ds.getPooledConnection();
            Connection conn = poolConn.getConnection();
            conn.close();
        } catch (SQLException se ) {
            if (usingEmbedded())
                throw se;
            else
                assertSQLState("22005",se);
        }
        // Chinese password
        try {
            J2EEDataSource.setBeanProperty(ds, "password", "\u4e10");
            PooledConnection poolConn= ds.getPooledConnection();
            Connection conn = poolConn.getConnection();
            conn.close();
        } catch (SQLException se ) {
            if (usingEmbedded())
                throw se;
View Full Code Here

TOP

Related Classes of javax.sql.ConnectionPoolDataSource

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.