Skip to content

Commit ff52855

Browse files
committed
Reduce repetitive logging when using a cached connection
1 parent 6ac424e commit ff52855

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/io/confluent/connect/jdbc/util/CachedConnectionProvider.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ public synchronized Connection getConnection() {
5656
log.info("The database connection is invalid. Reconnecting...");
5757
close();
5858
newConnection();
59+
} else {
60+
log.debug("Using existing database connection.");
61+
return connection;
5962
}
6063
} catch (SQLException sqle) {
6164
log.debug("Could not establish connection with database.", sqle);
6265
throw new ConnectException(sqle);
6366
}
64-
log.info("Database connection established.");
65-
return connection;
6667
}
6768

6869
@Override
@@ -83,6 +84,7 @@ private void newConnection() throws SQLException {
8384
log.debug("Attempting to open connection #{} to {}", count, provider);
8485
connection = provider.getConnection();
8586
onConnect(connection);
87+
log.info("Database connection established.");
8688
return;
8789
} catch (SQLException sqle) {
8890
attempts++;

0 commit comments

Comments
 (0)