Package javax.sql

Examples of javax.sql.PooledConnection


        // Test chinese database name.
        ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();
        J2EEDataSource.setBeanProperty(ds, "databaseName", "\u4e10");
        J2EEDataSource.setBeanProperty(ds, "createDatabase", "create");       

        PooledConnection poolConn = ds.getPooledConnection();
        Connection conn = poolConn.getConnection();
        conn.close();
        // Chinese user
        J2EEDataSource.setBeanProperty(ds, "user", "\u4e10");
        poolConn = ds.getPooledConnection();
        conn = poolConn.getConnection();
        conn.close();

        // Chinese password
        J2EEDataSource.setBeanProperty(ds, "password", "\u4e10");
        poolConn= ds.getPooledConnection();
        conn = poolConn.getConnection();
        conn.close();
       
        /* Add the created database for cleanup by tearDown() */
        databasesForCleanup.add("\u4e10");
    }
View Full Code Here


        {
            dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
            if (dncLogWriter != null) {
                dncLogWriter.traceEntry(this, "getPooledConnection");
            }
            PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, getUser(), getPassword());
            if (dncLogWriter != null) {
                dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
            }
            return pooledConnection;
        }
View Full Code Here

        {
            dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
            if (dncLogWriter != null) {
                dncLogWriter.traceEntry(this, "getPooledConnection", user, "<escaped>");
            }
            PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, user, password);
            if (dncLogWriter != null) {
                dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
            }
            return pooledConnection;
        }
View Full Code Here

            TestDataSourceFactory.getConnectionPoolDataSource();
        setDataSourceProperty(ds, "password", "mypassword");
        setDataSourceProperty(ds, "attributesAsPassword", Boolean.TRUE,
                              Boolean.TYPE);
        // DERBY-1586 caused a malformed url error here
        PooledConnection pc = ds.getPooledConnection();
        Connection c = pc.getConnection();
        c.close();
    }
View Full Code Here

        ConnectionPoolDataSource ds =
            TestDataSourceFactory.getConnectionPoolDataSource();
        setDataSourceProperty(ds, "attributesAsPassword", Boolean.TRUE,
                              Boolean.TYPE);
        try {
            PooledConnection pc =
                ds.getPooledConnection("username", "mypassword");
            fail("Expected getPooledConnection to fail.");
        } catch (SQLException e) {
            // expect error because of malformed url
            assertSQLState("XJ028", e);
View Full Code Here

        sh.invoke(cpds, args);
       
        // 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();
        conn = pc.getConnection();
        conn.close();
        conn = pc.getConnection();
        test(conn);
        conn.close();
        System.out.println("OK");
    }
View Full Code Here

        {
            LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
            if (dncLogWriter != null) {
                dncLogWriter.traceEntry(this, "getPooledConnection");
            }
            PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, getUser(), getPassword());
            if (dncLogWriter != null) {
                dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
            }
            return pooledConnection;
        }
View Full Code Here

        {
            LogWriter dncLogWriter = super.computeDncLogWriterForNewConnection("_cpds");
            if (dncLogWriter != null) {
                dncLogWriter.traceEntry(this, "getPooledConnection", user, "<escaped>");
            }
            PooledConnection pooledConnection = getPooledConnectionX(dncLogWriter, this, user, password);
            if (dncLogWriter != null) {
                dncLogWriter.traceExit(this, "getPooledConnection", pooledConnection);
            }
            return pooledConnection;
        }
View Full Code Here

         * @return a <code>Connection</code> value
         * @exception SQLException if an error occurs
         */
        protected Connection newConnection_() throws SQLException {
            ConnectionPoolDataSource ds = TestDataSourceFactory.getConnectionPoolDataSource();
            PooledConnection pc =
                ds.getPooledConnection(TestConfiguration.getCurrent().getUserName(),
                        TestConfiguration.getCurrent().getUserPassword());
            return pc.getConnection();
        }
View Full Code Here

        dscsp.setDatabaseName("wombat");
        //dscsp.setConnectionAttributes("unicode=true");
        dsp = dscsp;
      }

      PooledConnection pc = dsp.getPooledConnection();
      con1 = pc.getConnection();
      con1.setAutoCommit(false);
      Statement s = con1.createStatement();

      System.out.println(" In the first connection handle to the pooled connection, create physical session schema, create table t1 in it");
      System.out.println(" Insert some rows in physical SESSION.t1 table. Inspect the data.");
      s.executeUpdate("CREATE schema SESSION");
      s.executeUpdate("CREATE TABLE SESSION.t1(c21 int)");
      s.executeUpdate("insert into SESSION.t1 values(11)");
      s.executeUpdate("insert into SESSION.t1 values(12)");
      s.executeUpdate("insert into SESSION.t1 values(13)");
      ResultSet rs1 = s.executeQuery("select * from SESSION.t1"); //should return 3 rows for the physical table
      dumpRS(rs1);

      System.out.println(" Next declare a temp table with same name as physical table in SESSION schema.");
      System.out.println(" Insert some rows in temporary table SESSION.t1. Inspect the data");
      s.executeUpdate("declare global temporary table SESSION.t1(c11 int, c12 int) on commit preserve rows not logged");
      s.executeUpdate("insert into SESSION.t1 values(11,1)");
      rs1 = s.executeQuery("select * from SESSION.t1"); //should return 1 row for the temporary table
      dumpRS(rs1);
      System.out.println(" Now close the connection handle to the pooled connection");
      con1.commit();
      con1.close();
      con1=null;

      System.out.println(" Do another getConnection() to get a new connection handle to the pooled connection");
      con2 = pc.getConnection();
      s = con2.createStatement();
      System.out.println(" In this new handle, a select * from SESSION.t1 should be looking at the physical session table");
      rs1 = s.executeQuery("select * from SESSION.t1");
      dumpRS(rs1);

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.