Skip to content

Commit

Permalink
simplified call to executeSql()
Browse files Browse the repository at this point in the history
  • Loading branch information
nitincchauhan committed Feb 12, 2016
1 parent c7e3a8f commit e4b9128
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/zaxxer/hikari/pool/PoolBase.java
Expand Up @@ -353,7 +353,7 @@ private void setupConnection(final Connection connection) throws SQLException
connection.setCatalog(catalog);
}

executeSql(connection, config.getConnectionInitSql(), isIsolateInternalQueries && !isAutoCommit, false);
executeSql(connection, config.getConnectionInitSql(), true);

setNetworkTimeout(connection, networkTimeout);
}
Expand All @@ -377,7 +377,7 @@ private void checkDriverSupport(final Connection connection) throws SQLException
}
else {
try {
executeSql(connection, config.getConnectionTestQuery(), false, isIsolateInternalQueries && !isAutoCommit);
executeSql(connection, config.getConnectionTestQuery(), false);
}
catch (Throwable e) {
LOGGER.error("{} - Failed to execute connection test query. ({})", poolName, e.getMessage());
Expand Down Expand Up @@ -464,22 +464,22 @@ private void setNetworkTimeout(final Connection connection, final long timeoutMs
*
* @param connection the connection to initialize
* @param sql the SQL to execute
* @param isAutoCommit whether to commit the SQL after execution or not
* @param isCommit whether to commit the SQL after execution or not
* @throws SQLException throws if the init SQL execution fails
*/
private void executeSql(final Connection connection, final String sql, final boolean isCommit, final boolean isRollback) throws SQLException
private void executeSql(final Connection connection, final String sql, final boolean isCommit) throws SQLException
{
if (sql != null) {
try (Statement statement = connection.createStatement()) {
// connection was created a few milliseconds before, so set query timeout is omitted (we assume it will succeed)
statement.execute(sql);
}

if (!isReadOnly) {
if (isIsolateInternalQueries && !isReadOnly && !isAutoCommit) {
if (isCommit) {
connection.commit();
}
else if (isRollback) {
else {
connection.rollback();
}
}
Expand Down

0 comments on commit e4b9128

Please sign in to comment.