diff options
-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(); } |