diff options
author | Vitaly Takmazov | 2022-12-18 11:16:03 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2022-12-18 11:16:03 +0300 |
commit | eaf04f18001159cf5aaa3c9747a300b48e8d3f2f (patch) | |
tree | 999792417c3a3fe8c6048f94b354399738e67d1c /src/main/java/com/juick | |
parent | bb215f6373b32f0e54cdf04f9b88ced54785e54d (diff) |
Correct unwrapped DataSource connection usage
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r-- | src/main/java/com/juick/service/PostgreGINService.java | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/main/java/com/juick/service/PostgreGINService.java b/src/main/java/com/juick/service/PostgreGINService.java index ca326bd5..583836a7 100644 --- a/src/main/java/com/juick/service/PostgreGINService.java +++ b/src/main/java/com/juick/service/PostgreGINService.java @@ -49,11 +49,9 @@ public class PostgreGINService extends BaseJdbcService implements SearchService DataSource dataSource; private String escapeQuery(String searchString) { - try { - if (dataSource.getConnection().isWrapperFor(PGConnection.class)) { - PGConnection connection = dataSource.getConnection().unwrap(PGConnection.class); - return connection.escapeLiteral(searchString); - } + try (var connection = dataSource.getConnection()) { + var pg = connection.unwrap(PGConnection.class); + return pg.escapeLiteral(searchString); } catch (SQLException e) { e.printStackTrace(); } |