Skip to content

Commit

Permalink
Merge pull request #3072 from mapfish/close-connection
Browse files Browse the repository at this point in the history
Close the database connection
  • Loading branch information
sebr72 authored Oct 20, 2023
2 parents 53cf70f + 29f6667 commit 8408732
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,22 @@ public final Print getJasperPrint(
}
}
if (template.getJdbcUrl() != null) {
Connection connection;
if (template.getJdbcUser() != null) {
connection =
DriverManager.getConnection(
template.getJdbcUrl(), template.getJdbcUser(), template.getJdbcPassword());
} else {
connection = DriverManager.getConnection(template.getJdbcUrl());
}

print = fillManager.fill(jasperTemplateBuild.getAbsolutePath(), values.asMap(), connection);
Connection connection = null;
try {
if (template.getJdbcUser() != null) {
connection =
DriverManager.getConnection(
template.getJdbcUrl(), template.getJdbcUser(), template.getJdbcPassword());
} else {
connection = DriverManager.getConnection(template.getJdbcUrl());
}

print = fillManager.fill(jasperTemplateBuild.getAbsolutePath(), values.asMap(), connection);
} finally {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
} else {
JRDataSource dataSource;
if (template.getTableDataKey() != null) {
Expand Down

0 comments on commit 8408732

Please sign in to comment.