Search in sources :

Example 1 with NewProxyConnection

use of com.mchange.v2.c3p0.impl.NewProxyConnection in project druid by alibaba.

the class TestPSCache method unwrap.

public static MockConnection unwrap(Connection conn) throws Exception {
    if (conn instanceof ConnectionHandle) {
        ConnectionHandle handle = (ConnectionHandle) conn;
        return (MockConnection) handle.getInternalConnection();
    }
    if (conn instanceof NewProxyConnection) {
        NewProxyConnection handle = (NewProxyConnection) conn;
        Field field = NewProxyConnection.class.getDeclaredField("inner");
        field.setAccessible(true);
        return (MockConnection) field.get(handle);
    }
    return conn.unwrap(MockConnection.class);
}
Also used : Field(java.lang.reflect.Field) NewProxyConnection(com.mchange.v2.c3p0.impl.NewProxyConnection) ConnectionHandle(com.jolbox.bonecp.ConnectionHandle) MockConnection(com.alibaba.druid.mock.MockConnection)

Example 2 with NewProxyConnection

use of com.mchange.v2.c3p0.impl.NewProxyConnection in project druid by alibaba.

the class TestLRU method unwrap.

public static MockConnection unwrap(Connection conn) throws Exception {
    if (conn instanceof ConnectionHandle) {
        ConnectionHandle handle = (ConnectionHandle) conn;
        return (MockConnection) handle.getInternalConnection();
    }
    if (conn instanceof NewProxyConnection) {
        NewProxyConnection handle = (NewProxyConnection) conn;
        Field field = NewProxyConnection.class.getDeclaredField("inner");
        field.setAccessible(true);
        return (MockConnection) field.get(handle);
    }
    return conn.unwrap(MockConnection.class);
}
Also used : Field(java.lang.reflect.Field) NewProxyConnection(com.mchange.v2.c3p0.impl.NewProxyConnection) ConnectionHandle(com.jolbox.bonecp.ConnectionHandle) MockConnection(com.alibaba.druid.mock.MockConnection)

Aggregations

MockConnection (com.alibaba.druid.mock.MockConnection)2 ConnectionHandle (com.jolbox.bonecp.ConnectionHandle)2 NewProxyConnection (com.mchange.v2.c3p0.impl.NewProxyConnection)2 Field (java.lang.reflect.Field)2