Skip to content

Commit

Permalink
fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
jw-itq committed Nov 28, 2024
1 parent 5d2fabe commit 7ab43fd
Showing 1 changed file with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,15 @@ public void applySchemaChange(SchemaChangeEvent event) {
throw new RuntimeException("Failed to load MySQL JDBC driver", e);
}

Connection conn = null;
try {
conn =
DriverManager.getConnection(
sinkConfig.getJdbcUrl(),
sinkConfig.getUsername(),
sinkConfig.getPassword());
try (Connection conn =
DriverManager.getConnection(
sinkConfig.getJdbcUrl(),
sinkConfig.getUsername(),
sinkConfig.getPassword())) {
SchemaUtils.applySchemaChange(event, conn, sinkTablePath);
} catch (SQLException e) {
throw new CatalogException(
String.format("Failed connecting to %s via JDBC.", sinkConfig.getJdbcUrl()), e);
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
log.error("Failed to close JDBC connection", e);
}
}
}
}

Expand Down

0 comments on commit 7ab43fd

Please sign in to comment.