Git Product home page Git Product logo

Comments (5)

ttddyy avatar ttddyy commented on July 22, 2024

@sudhipanamdocs Thanks for the report.

While I'll take a look, as a workaround, you can use ProxyJdbcObject#getTarget to retrieve the original connection:

if (conn instanceof ProxyJdbcObject) {
    Connection original = (Connection) ((ProxyJdbcObject) conn).getTarget();
    // compare with another connection or its underlying connection if it is an another proxy
}

Out of curiosity, what is your usecase to make a proxy DataSource managed by a connection pool?
Usually, you want to observe how your application interacts with DataSource, not how the connection pool works with underlying DataSource unless you are writing your own connection pool, I presume.

So, in general, it is like:
Application -> Proxy DataSource -> Connection Pool Library -> Actual DataSource

from datasource-proxy.

sudhipanamdocs avatar sudhipanamdocs commented on July 22, 2024

@ttddyy I am not using Datasource, I am using raw jdbc to create Connections(Drivermanager.getconnection()). it is legacy application. To monitor jdbc calls we are using this library and creating connection proxy instead of connections by using jdkJdbcProxyFactory.createConnection().

from datasource-proxy.

ttddyy avatar ttddyy commented on July 22, 2024

@sudhipanamdocs Thanks for sharing the usage.

As a workaround, you may create another proxy on top of the created proxy connection to handle equals method.

class MyInvocationHandler implements InvocationHandler {
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (method.getName().equals("equals")) {
            Object target = args[0];
            if (proxy.equals(target)) {
                return true;
            }
            if (target instanceof ProxyJdbcObject) {
                Object originalConnection = ((ProxyJdbcObject)proxy).getTarget();
                Object targetOriginal = ((ProxyJdbcObject)target).getTarget();
                return originalConnection.equals(targetOriginal);
            }
            return false;
        }
        return method.invoke(proxy, args);
    }
}

from datasource-proxy.

sudhipanamdocs avatar sudhipanamdocs commented on July 22, 2024

@ttddyy Please release 1.10 version. We are waiting for it.

from datasource-proxy.

sudhipanamdocs avatar sudhipanamdocs commented on July 22, 2024

@ttddyy can we release the milestone 1.10 before other open issues for milestone.

from datasource-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.