Skip to content

Commit

Permalink
Merge pull request #3081 from mapfish/backport/3072-to-3.29
Browse files Browse the repository at this point in the history
[Backport 3.29] Close the database connection
  • Loading branch information
sebr72 authored Oct 20, 2023
2 parents 57023fb + 6bbbdec commit 602bd1c
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,22 @@ public final Print getJasperPrint(

}
if (template.getJdbcUrl() != null) {
Connection connection;
if (template.getJdbcUser() != null) {
connection = DriverManager.getConnection(
Connection connection = null;
try {
if (template.getJdbcUser() != null) {
connection = DriverManager.getConnection(
template.getJdbcUrl(), template.getJdbcUser(), template.getJdbcPassword());
} else {
connection = DriverManager.getConnection(template.getJdbcUrl());
}
} else {
connection = DriverManager.getConnection(template.getJdbcUrl());
}

print = fillManager.fill(
jasperTemplateBuild.getAbsolutePath(),
values.asMap(),
connection);
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 602bd1c

Please sign in to comment.