Package com.alibaba.druid.proxy.jdbc

Examples of com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl


    public ConnectionProxy wrap(Connection connection, Properties info) {
        if (connection == null) {
            return null;
        }

        return new ConnectionProxyImpl(dataSource, connection, info, dataSource.createConnectionId());
    }
View Full Code Here


    public ConnectionProxy wrap(Connection connection, Properties info) {
        if (connection == null) {
            return null;
        }

        return new ConnectionProxyImpl(dataSource, connection, info, dataSource.createConnectionId());
    }
View Full Code Here

    public void test_driver_wrap() throws Exception {
        DruidDriver driver = new DruidDriver();

        {
            ConnectionProxyImpl conn = (ConnectionProxyImpl) driver.connect("jdbc:wrap-jdbc:filters=:name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true",
                                                                            new Properties());
            Assert.assertEquals(0, conn.getDirectDataSource().getProxyFilters().size());
            conn.close();
        }
        {
            ConnectionProxyImpl conn = (ConnectionProxyImpl) driver.connect("jdbc:wrap-jdbc:filters=,:name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true",
                                                                            new Properties());
            Assert.assertEquals(0, conn.getDirectDataSource().getProxyFilters().size());
            conn.close();
        }
        {
            ConnectionProxyImpl conn = (ConnectionProxyImpl) driver.connect("jdbc:wrap-jdbc:filters=,:jdbc:derby:memory:driverWrapperTestDB;create=true",
                                                                            new Properties());
            Assert.assertEquals(0, conn.getDirectDataSource().getProxyFilters().size());
            conn.close();
        }
        {
            ConnectionProxyImpl conn = (ConnectionProxyImpl) driver.connect("jdbc:wrap-jdbc:filters=,:name=:jdbc:derby:memory:driverWrapperTestDB;create=true",
                                                                            new Properties());
            Assert.assertEquals(0, conn.getDirectDataSource().getProxyFilters().size());
            conn.close();
        }
        {
            ConnectionProxyImpl conn = (ConnectionProxyImpl) driver.connect("jdbc:wrap-jdbc:driver=:filters=,:name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true",
                                                                            new Properties());
            Assert.assertEquals(0, conn.getDirectDataSource().getProxyFilters().size());
            conn.close();
        }
        {
            ConnectionProxyImpl conn = (ConnectionProxyImpl) driver.connect("jdbc:wrap-jdbc:name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true",
                                                                            new Properties());
            Assert.assertEquals(0, conn.getDirectDataSource().getProxyFilters().size());
            conn.close();
        }
        {
            ConnectionProxyImpl conn = (ConnectionProxyImpl) driver.connect("jdbc:wrap-jdbc:filters="
                                                                                    + PublicJdbcFilterAdapter.class.getName()
                                                                                    + ":name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true",
                                                                            new Properties());
            Assert.assertEquals(1, conn.getDirectDataSource().getProxyFilters().size());
            conn.close();
        }
        {
            Exception error = null;
            try {
                driver.connect("jdbc:wrap-jdbc:filters=" + PrivateJdbcFilterAdapter.class.getName()
View Full Code Here

    public void test_clone() throws Exception {
        Class.forName("com.alibaba.druid.proxy.DruidDriver");

        DruidDriver driver = (DruidDriver) DriverManager.getDriver(url);

        ConnectionProxyImpl connection = (ConnectionProxyImpl) driver.connect(url, new Properties());

        connection.getRawObject();

        FilterChain filterChain = (FilterChain) connection.createChain();
        filterChain.cloneChain();

        DataSourceProxyImpl dataSource = (DataSourceProxyImpl) connection.getDirectDataSource();
        dataSource.getId();
        Assert.assertEquals(4, dataSource.getProxyFilters().size());
        Assert.assertEquals(4, dataSource.getFilterClasses().length);
        Assert.assertNotNull(dataSource.getCreatedTime());
        Assert.assertTrue(dataSource.getCreatedTime().getTime() != 0);
        Assert.assertEquals("org.apache.derby.jdbc.EmbeddedDriver", dataSource.getRawDriverClassName());

        Assert.assertEquals(url, dataSource.getUrl());
        Assert.assertEquals("jdbc:derby:classpath:petstore-db", dataSource.getRawUrl());
        Assert.assertEquals(10, dataSource.getRawDriverMajorVersion());
        Assert.assertEquals(9, dataSource.getRawDriverMinorVersion());

        Assert.assertFalse(connection.isWrapperFor(com.mysql.jdbc.Connection.class));
        Assert.assertTrue(connection.isWrapperFor(ConnectionProxyImpl.class));
        Assert.assertTrue(connection.isWrapperFor(org.apache.derby.impl.jdbc.EmbedConnection.class));
        Assert.assertNotNull(connection.unwrap(ConnectionProxyImpl.class));
        Assert.assertNull(connection.unwrap(null));

        org.apache.derby.impl.jdbc.EmbedConnection derbyConnection = connection.unwrap(org.apache.derby.impl.jdbc.EmbedConnection.class);
        Assert.assertNotNull(derbyConnection);

        Statement statement = connection.createStatement();
        Assert.assertFalse(statement.isWrapperFor(com.mysql.jdbc.Statement.class));
        Assert.assertFalse(statement.isWrapperFor(null));
        Assert.assertTrue(statement.isWrapperFor(org.apache.derby.impl.jdbc.EmbedStatement.class));

        org.apache.derby.impl.jdbc.EmbedStatement rayStatement = statement.unwrap(org.apache.derby.impl.jdbc.EmbedStatement.class);
View Full Code Here

        FilterEventAdapter filter = new FilterEventAdapter() {
        };

        String sql = "SELECT * FROM PATROL";
        ConnectionProxy connection = new ConnectionProxyImpl(dataSource, null, new Properties(), 1001);
        final PreparedStatementProxy statement = new PreparedStatementProxyImpl(connection, null, sql, 1002);

        {
            FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {

View Full Code Here

        FilterEventAdapter filter = new FilterEventAdapter() {
        };
        filter.init(dataSource);

        ConnectionProxyImpl rawConnection = new ConnectionProxyImpl(null, null, new Properties(), 0) {

            public void setClientInfo(String name, String value) throws SQLClientInfoException {

            }
        };

        ConnectionProxyImpl connection = new ConnectionProxyImpl(dataSource, rawConnection, new Properties(), 1001);

        connection.setClientInfo("name", null);
    }
View Full Code Here

        filter.init(dataSource);

        config.getFilters().add(filter);

        String sql = "CALL P_0(?, ?)";
        CallableStatementProxyImpl rawCallStatement = new FakeCallableStatement(new ConnectionProxyImpl(null, null, null, 0), null, sql, 1001);

        ConnectionProxy connection = new ConnectionProxyImpl(dataSource, null, new Properties(), 1001);
        CallableStatementProxyImpl cstmt = new CallableStatementProxyImpl(connection, rawCallStatement, sql, 2001);

        cstmt.registerOutParameter(1, Types.VARCHAR);
        cstmt.registerOutParameter(1, Types.VARCHAR, "VARCHAR");
        cstmt.registerOutParameter(1, Types.VARCHAR, 3);
View Full Code Here

    public ConnectionProxy wrap(Connection connection, Properties info) {
        if (connection == null) {
            return null;
        }

        return new ConnectionProxyImpl(dataSource, connection, info, dataSource.createConnectionId());
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl

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.