Skip to content
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

Added Support For beginRequest and endRequest #2079

Closed
26 changes: 25 additions & 1 deletion src/main/java/com/zaxxer/hikari/pool/PoolEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.ScheduledFuture;
Expand Down Expand Up @@ -78,6 +79,17 @@ void recycle()
{
Deeptanshu-Chowdhuri marked this conversation as resolved.
Show resolved Hide resolved
if (connection != null) {
this.lastAccessed = currentTime();
try {
DatabaseMetaData dm = connection.getMetaData();
if (dm!=null){
if (dm.getJDBCMajorVersion() > 4 ||
(dm.getJDBCMajorVersion() == 4 && dm.getJDBCMinorVersion() >= 3)) {
Comment on lines +83 to +86
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic should not be executed every time. Can this be moved somewhere so the calculation of if the feature is supported is only run once. Calling getMetaData might not be cheap.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment has been addressed in pull request #2126

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lfbayer FYI I've asked Deeptanshu to close this PR as his internship at Oracle is now over. We will continue his work in PR 2126.

connection.endRequest();
}
}
} catch (SQLException e) {
LOGGER.warn("endRequest Failed for: {},({})",connection,e.getMessage());
}
hikariPool.recycle(this);
}
}
Expand All @@ -98,7 +110,19 @@ public void setKeepalive(ScheduledFuture<?> keepalive) {

Connection createProxyConnection(final ProxyLeakTask leakTask)
{
Deeptanshu-Chowdhuri marked this conversation as resolved.
Show resolved Hide resolved
return ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, isReadOnly, isAutoCommit);
Connection newproxyconn= ProxyFactory.getProxyConnection(this, connection, openStatements, leakTask, isReadOnly, isAutoCommit);
try {
DatabaseMetaData dm=connection.getMetaData();
if (dm!=null){
if (dm.getJDBCMajorVersion() > 4 ||
(dm.getJDBCMajorVersion() == 4 && dm.getJDBCMinorVersion() >= 3)) {
connection.beginRequest();
}
}
} catch (SQLException e) {
LOGGER.warn("beginRequest Failed for: {}, ({})",connection,e.getMessage());
}
return newproxyconn;
}

void resetConnectionState(final ProxyConnection proxyConnection, final int dirtyBits) throws SQLException
Expand Down