Skip to content

Commit

Permalink
Merge pull request #3079 from mapfish/backport/3072-to-3.27
Browse files Browse the repository at this point in the history
[Backport 3.27] Close the database connection
  • Loading branch information
sebr72 authored Oct 20, 2023
2 parents 0385679 + 2c3ab5a commit f050bc3
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,21 @@ 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());
}

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

Please sign in to comment.