Skip to content

Commit

Permalink
Merge pull request #3082 from mapfish/backport/3072-to-3.30
Browse files Browse the repository at this point in the history
[Backport 3.30] Close the database connection
  • Loading branch information
sebr72 committed Oct 20, 2023
2 parents d460916 + ce55412 commit d0d17fc
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,23 @@ 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(
} 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;
Expand Down

0 comments on commit d0d17fc

Please sign in to comment.