New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
what's the purpose to generate HikariProxyConnection by javaassist since you already write ProxyConnection ? #1198
Comments
The proxies delegate to the real driver classes. Some proxies, like the one for ResultSet, only intercept a few methods. Without the code generation, the proxy would have to implement all 50+ methods which simply delegate to the wrapped instance. Code generation, based on reflection, also means that nothing needs to be done when a new JDK version introduces new JDBC methods to existing interfaces. |
@brettwooldridge thanks a lot |
Although the ProxyConnection is a abstract class, as a connection-pooling, must impl this method in fact. Generate these class just for compatible with high version JDK? |
A concrete class is generated from the abstract {
try {
return delegate.method($$);
} catch (SQLException e) {
throw checkException(e);
}
} ... which allows us to inspect the exception to see if it represents a disconnection error. A side-effect is that, yes, the code ends of being flexible with respect to JDBC API changes -- at least all that we have encountered so far. |
@brettwooldridge thanks for the "official" response! |
according to the source code, I found ProxyConnection already do a lot of things, HikariProxyConnection only add a try catch block to every method.
I was so confused. it would be nice if anyone can give an explanation. thanks in advance!
The text was updated successfully, but these errors were encountered: