Package com.alibaba.druid.pool

Examples of com.alibaba.druid.pool.DruidPooledConnection


        JdbcStatManager.getInstance().setStatContext(null);
    }

    public void test_basic() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        Assert.assertEquals(null, conn.unwrap(Date.class));
        Assert.assertEquals(null, conn.unwrap(null));
        Assert.assertEquals(((ConnectionProxy) conn.getConnection()).getRawObject(), conn.unwrap(Connection.class));

        Assert.assertEquals(false, conn.isWrapperFor(null));
        Assert.assertEquals(true, conn.isWrapperFor(DruidPooledConnection.class));
        Assert.assertEquals(true, conn.isWrapperFor(Connection.class));

        Assert.assertEquals("SELECT 1", conn.nativeSQL("SELECT 1"));

        conn.toString();

        conn.close();
        conn.toString();
    }
View Full Code Here


        conn.close();
        conn.toString();
    }

    public void test_prepareStatement_error() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        conn.getConnection().close();

        {
            SQLException error = null;
            try {
                conn.prepareStatement("SELECT 1");
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement_error2() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        conn.getConnection().close();

        {
            SQLException error = null;
            try {
                conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement_error3() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        conn.getConnection().close();

        {
            SQLException error = null;
            try {
                conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
                                      ResultSet.HOLD_CURSORS_OVER_COMMIT);
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement_error4() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        {
            SQLException error = null;
            try {
                conn.prepareStatement(null, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
                                      ResultSet.HOLD_CURSORS_OVER_COMMIT);
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement_error5() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        {
            SQLException error = null;
            try {
                conn.prepareStatement(null, new int[0]);
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement_error6() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        conn.getConnection().close();
        {
            SQLException error = null;
            try {
                conn.prepareStatement("SELECT 1", new int[0]);
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement_error7() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        conn.getConnection().close();
        {
            SQLException error = null;
            try {
                conn.prepareStatement("SELECT 1", new String[0]);
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement_error8() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        conn.getConnection().close();
        {
            SQLException error = null;
            try {
                conn.prepareStatement("SELECT 1", 0);
            } catch (SQLException ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
        }

        conn.close();
    }
View Full Code Here

        conn.close();
    }

    public void test_prepareStatement() throws Exception {
        DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

        MockPreparedStatement raw = null;
        {
            PreparedStatement stmt = conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY,
                                                           ResultSet.CONCUR_READ_ONLY);
            raw = stmt.unwrap(MockPreparedStatement.class);
            stmt.close();
        }
        {
            PreparedStatement stmt = conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY,
                                                           ResultSet.CONCUR_READ_ONLY);
            Assert.assertSame(raw, stmt.unwrap(MockPreparedStatement.class));
            stmt.close();
        }

        conn.close();
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.pool.DruidPooledConnection

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.