-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 (new version) #2126
base: dev
Are you sure you want to change the base?
Changes from 1 commit
aa9ee1e
9c3f087
0650456
5d5b6e6
eed24d2
a8e905e
248bc3b
726876f
b21683c
df4bfce
116e3ba
0b35a72
2b9a35c
5761a5f
5b845f2
a72b575
a70ccb0
56ae757
71e238a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ final class PoolEntry implements IConcurrentBagEntry | |
|
||
private final boolean isReadOnly; | ||
private final boolean isAutoCommit; | ||
private boolean isJDBC43OrLater; | ||
|
||
static | ||
{ | ||
|
@@ -70,6 +71,17 @@ final class PoolEntry implements IConcurrentBagEntry | |
this.isAutoCommit = isAutoCommit; | ||
this.lastAccessed = currentTime(); | ||
this.openStatements = new FastList<>(Statement.class, 16); | ||
boolean isJDBC43OrLater = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any specific reason to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I imagine there is a desired to make the member variable |
||
try { | ||
DatabaseMetaData dm = connection.getMetaData(); | ||
isJDBC43OrLater = ((dm != null) && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the connection instance has the methods "beginRequest" and "endRequest", wouldn't that be sufficient to know we can call them, rather than doing a version check? Maybe using reflection on the connection instance? I'm wondering if adding the call to getMetaData has any performance implications. It also seems like it would better to set this pool-wide, rather than have the value calculated for every new connection in the pool. I can't imagine that you would have a pool that would have different JDBC versions for each connection. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the feedback. I chose to do it for each connection because I thought that one could change the version of the driver that is in the application classpath and the pool would start using a new driver, but if that is not possible I propose the following approach: I will move the check to PoolBase.checkDriverSupport(Connection) and store the value(s) in a private member. This/these value(s) will be added as a parameter on the constructor of the PoolEntry class, and passed in the PoolBase.newEntry() method. Concerning using relection instead of database metadata, I could argue that if Hikari starts using new JDBC functionality in the future, the code could end up with several boolean variables (one for each method present in from specific version of the JDBC standard) instead of to int values jdbcMajorVersion and jdbcMinorVersion. I am new to Hikari, so please let me know which choice you prefer and I will comply. |
||
(dm.getJDBCMajorVersion() > 4) || | ||
(dm.getJDBCMajorVersion() == 4 && dm.getJDBCMinorVersion() >= 3) | ||
)); | ||
} catch (SQLException sqlEx) { | ||
LOGGER.warn("getMetaData Failed for: {},({})", connection, sqlEx.getMessage()); | ||
} | ||
this.isJDBC43OrLater = isJDBC43OrLater; | ||
} | ||
|
||
/** | ||
|
@@ -80,12 +92,8 @@ void recycle() | |
if (connection != null) { | ||
this.lastAccessed = currentTime(); | ||
try { | ||
DatabaseMetaData dm = connection.getMetaData(); | ||
if (dm!=null){ | ||
if (dm.getJDBCMajorVersion() > 4 || | ||
(dm.getJDBCMajorVersion() == 4 && dm.getJDBCMinorVersion() >= 3)) { | ||
connection.endRequest(); | ||
} | ||
if (this.isJDBC43OrLater){ | ||
connection.endRequest(); | ||
} | ||
} catch (SQLException e) { | ||
LOGGER.warn("endRequest Failed for: {},({})",connection,e.getMessage()); | ||
|
@@ -112,12 +120,8 @@ Connection createProxyConnection(final ProxyLeakTask leakTask) | |
{ | ||
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(); | ||
} | ||
if (this.isJDBC43OrLater){ | ||
connection.beginRequest(); | ||
} | ||
} catch (SQLException e) { | ||
LOGGER.warn("beginRequest Failed for: {}, ({})",connection,e.getMessage()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The choice of variable is inconsistent with the codebase