Package javax.sql

Examples of javax.sql.ConnectionPoolDataSource


    private synchronized void registerPool(
        String username, String password)
        throws javax.naming.NamingException, SQLException {

        ConnectionPoolDataSource cpds = testCPDS(username, password);

        Integer userMax = getPerUserMaxActive(username);
        int maxActive = (userMax == null) ?
            getDefaultMaxActive() : userMax.intValue();
        userMax = getPerUserMaxIdle(username);
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.cpds;
        if (cpds == null) {           
            Context ctx = null;
            if (jndiEnvironment == null) {
                ctx = new InitialContext();               
            } else {
                ctx = new InitialContext(jndiEnvironment);
            }
            cpds = (ConnectionPoolDataSource) ctx.lookup(dataSourceName);
        }
       
        // 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 java.sql.SQLException
    {
        try
        {
            Class c = Class.forName("oracle.jdbc.pool.OracleConnectionPoolDataSource");
            ConnectionPoolDataSource instance =
                            (ConnectionPoolDataSource) c.newInstance();

            // use introspection to set the url in order to avoid import
            // of JDBC specific classes
            Method m = c.getMethod("setURL", new Class[]{ String.class });
View Full Code Here

        assertSame("Unwrap returned wrong object.", ds, ds2);
    }

    public void testUnwrapConnectionPoolDataSource() {
        try {
            ConnectionPoolDataSource cpds =
                ds.unwrap(ConnectionPoolDataSource.class);
            fail("Unwrap didn't fail.");
        } catch (SQLException e) {
            assertSQLState("XJ128", e);
        }
View Full Code Here

     */
    public void testConnectionErrorEvent() throws SQLException, Exception
    {
        AssertEventCatcher aes12 = new AssertEventCatcher(12);
        //Get the correct ConnectionPoolDataSource object
        ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();

        PooledConnection pc = ds.getPooledConnection();
        //Add a connection event listener to ConnectionPoolDataSource
        pc.addConnectionEventListener(aes12);
        Connection conn = pc.getConnection();
       
        dropTable(conn, "TAB1");
View Full Code Here

     * </p>
     */
    public void test_jdbc4_1() throws Exception
    {
        DataSource  ds = JDBCDataSource.getDataSource();
        ConnectionPoolDataSource cpds = J2EEDataSource.getConnectionPoolDataSource();
        XADataSource xads = J2EEDataSource.getXADataSource();

        vetDSjdbc4_1( ds );
        vetDSjdbc4_1( cpds );
        vetDSjdbc4_1( xads );
View Full Code Here

     */
    private static void
        collectClassesFromConnectionPoolDataSource(Set<ClassInfo> classes)
        throws SQLException
    {
        ConnectionPoolDataSource cpds = J2EEDataSource.getConnectionPoolDataSource();
        addClass(classes,
                 cpds.getClass(), javax.sql.ConnectionPoolDataSource.class);

        PooledConnection pc =
            cpds.getPooledConnection(TestConfiguration.getCurrent().getUserName(),
                    TestConfiguration.getCurrent().getUserPassword());
        addClass(classes, pc.getClass(), javax.sql.PooledConnection.class);

        collectClassesFromConnection(pc.getConnection(), classes);

View Full Code Here

        if (xa) {
            XADataSource ds = J2EEDataSource.getXADataSource();
            J2EEDataSource.setBeanProperty(ds, "createDatabase", "create");
            pooledConnection = ds.getXAConnection();
        } else {
            ConnectionPoolDataSource ds =
                J2EEDataSource.getConnectionPoolDataSource();
            J2EEDataSource.setBeanProperty(ds, "createDatabase", "create");
            pooledConnection = ds.getPooledConnection();
        }
        StatementEventListener listener = new StatementEventListener() {
                public void statementClosed(StatementEvent event) {
                    closedStatement = event.getStatement();
                    closedCount++;
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 (String property : attrs.keySet()) {
            Object value = attrs.get(property);
            JDBCDataSource.setBeanProperty(cpds, property, value);
        }
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.