Skip to content

Commit

Permalink
Close the database connection
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Oct 13, 2023
1 parent 9776ad4 commit 29f6667
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 29f6667

Please sign in to comment.