Comments (5)
@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.
@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.
@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.
@ttddyy Please release 1.10 version. We are waiting for it.
from datasource-proxy.
@ttddyy can we release the milestone 1.10 before other open issues for milestone.
from datasource-proxy.
Related Issues (20)
- Properly call before/after method callback on `ProxyDataSource#getConnection`
- module-info.java HOT 2
- Add `ProxyDataSourceBuilder#buildProxy()`
- Add `ProxyJdbcObject#getProxyConfig`
- Connection is not returned to the pool if connection.getTransactionIsolation() throws an exception HOT 1
- Possibility of intercepting method getConnection() if exception is thrown by original DataSource HOT 2
- equals method of ProxyLogicSupport class not working as expected. HOT 1
- Expose proxy object to method callback
- Reduce transaction Isolation level queries in ProxyDataSource with HikariCP and PostgreSQL HOT 2
- Use monotonic time to measure elapsed time in SystemStopWatch
- Failed to perform getConnection in datasource-proxy 1.10 HOT 3
- Make "AbstractQueryLogEntryCreator#chompIfEndWith" defensive for empty string
- Micrometer support HOT 2
- Got number of type instead null HOT 1
- Add SQL Format Option HOT 1
- Proxying generated keys not working with MS-SQL server data source HOT 4
- Document about Jakarta namespace support HOT 3
- Setting different names for each DataSource used by a routing DataSource HOT 3
- Support Quarkus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasource-proxy.