@@ -253,7 +253,8 @@ public boolean delete(Key key) {
253253 String .format (
254254 "DELETE FROM %s WHERE %s = ?" ,
255255 tableIdentifier , PostgresUtils .wrapFieldNamesWithDoubleQuotes (pkForTable ));
256- try (PreparedStatement preparedStatement = client .getConnection ().prepareStatement (deleteSQL )) {
256+ try (PreparedStatement preparedStatement =
257+ queryExecutor .prepareStatementWithTimeout (client .getConnection (), deleteSQL )) {
257258 preparedStatement .setString (1 , key .toString ());
258259 int rowsDeleted = preparedStatement .executeUpdate ();
259260 return rowsDeleted > 0 ;
@@ -320,7 +321,7 @@ public BulkDeleteResult delete(Set<Key> keys) {
320321 LOGGER .debug ("Bulk delete SQL: {}" , deleteSQL );
321322
322323 try (Connection conn = client .getPooledConnection ();
323- PreparedStatement ps = conn . prepareStatement ( deleteSQL )) {
324+ PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( conn , deleteSQL )) {
324325 int deletedCount = ps .executeUpdate ();
325326 LOGGER .debug ("Bulk deleted {} rows" , deletedCount );
326327 return new BulkDeleteResult (deletedCount );
@@ -336,7 +337,7 @@ public boolean deleteAll() {
336337 LOGGER .debug ("Delete all SQL: {}" , deleteSQL );
337338
338339 try (Connection conn = client .getPooledConnection ();
339- PreparedStatement ps = conn . prepareStatement ( deleteSQL )) {
340+ PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( conn , deleteSQL )) {
340341 int deletedCount = ps .executeUpdate ();
341342 LOGGER .debug ("Deleted all {} rows" , deletedCount );
342343 return true ;
@@ -402,7 +403,7 @@ public boolean bulkUpsert(Map<Key, Document> documents) {
402403 LOGGER .debug ("Bulk upsert SQL: {}" , sql );
403404
404405 try (Connection conn = client .getPooledConnection ();
405- PreparedStatement ps = conn . prepareStatement ( sql )) {
406+ PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( conn , sql )) {
406407
407408 for (Map .Entry <Key , TypedDocument > entry : parsedDocuments .entrySet ()) {
408409 TypedDocument parsed = entry .getValue ();
@@ -499,7 +500,7 @@ public boolean bulkCreateOrReplace(Map<Key, Document> documents) {
499500 LOGGER .debug ("Bulk createOrReplace SQL: {}" , sql );
500501
501502 try (Connection conn = client .getPooledConnection ();
502- PreparedStatement ps = conn . prepareStatement ( sql )) {
503+ PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( conn , sql )) {
503504
504505 for (Map .Entry <Key , TypedDocument > entry : parsedDocuments .entrySet ()) {
505506 TypedDocument parsed = entry .getValue ();
@@ -680,7 +681,8 @@ private PreparedStatement getPreparedStatementForQuery(
680681 throws SQLException {
681682 String selectQuery =
682683 String .format ("SELECT * FROM %s WHERE %s = ANY(?)" , tableIdentifier , quotedPkColumn );
683- PreparedStatement preparedStatement = connection .prepareStatement (selectQuery );
684+ PreparedStatement preparedStatement =
685+ queryExecutor .prepareStatementWithTimeout (connection , selectQuery );
684686
685687 String [] keyArray = documents .keySet ().stream ().map (Key ::toString ).toArray (String []::new );
686688 Array sqlArray = connection .createArrayOf (pkType .getSqlType (), keyArray );
@@ -959,7 +961,7 @@ private boolean executeKeyUpdate(
959961
960962 LOGGER .debug ("Executing key update SQL: {}" , sql );
961963
962- try (PreparedStatement ps = connection . prepareStatement ( sql )) {
964+ try (PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( connection , sql )) {
963965 int idx = 1 ;
964966 for (Object param : params ) {
965967 ps .setObject (idx ++, param );
@@ -1058,7 +1060,7 @@ private int executeBatchUpdate(
10581060
10591061 LOGGER .debug ("Executing batch update SQL: {} for {} keys" , sql , keys .size ());
10601062
1061- try (PreparedStatement ps = connection . prepareStatement ( sql )) {
1063+ try (PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( connection , sql )) {
10621064 for (int i : order ) {
10631065 int idx = 1 ;
10641066 for (Object param : allKeyParams .get (i )) {
@@ -1264,7 +1266,7 @@ private void executeUpdate(
12641266
12651267 LOGGER .debug ("Executing update SQL: {}" , sql );
12661268
1267- try (PreparedStatement ps = connection . prepareStatement ( sql )) {
1269+ try (PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( connection , sql )) {
12681270 int idx = 1 ;
12691271 for (Object param : params ) {
12701272 ps .setObject (idx ++, param );
@@ -1580,7 +1582,7 @@ Object convertTimestampForType(long epochMillis, PostgresDataType type) {
15801582
15811583 private int executeUpdate (String sql , TypedDocument parsed ) throws SQLException {
15821584 try (Connection conn = client .getPooledConnection ();
1583- PreparedStatement ps = conn . prepareStatement ( sql )) {
1585+ PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( conn , sql )) {
15841586 int index = 1 ;
15851587 for (String column : parsed .getColumns ()) {
15861588 setParameter (
@@ -1749,7 +1751,7 @@ private boolean executeUpsert(String sql, List<String> allColumns, TypedDocument
17491751 long ta = System .nanoTime ();
17501752 try (Connection conn = client .getPooledConnection ()) {
17511753 long tb = System .nanoTime ();
1752- try (PreparedStatement ps = conn . prepareStatement ( sql )) {
1754+ try (PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( conn , sql )) {
17531755 int index = 1 ;
17541756 Set <String > parsedColumns = new HashSet <>(parsed .getColumns ());
17551757 for (String column : allColumns ) {
@@ -1778,7 +1780,7 @@ private boolean executeUpsert(String sql, List<String> allColumns, TypedDocument
17781780 private boolean executeUpsertReturningIsInsert (
17791781 String sql , List <String > allColumns , TypedDocument parsed ) throws SQLException {
17801782 try (Connection conn = client .getPooledConnection ();
1781- PreparedStatement ps = conn . prepareStatement ( sql )) {
1783+ PreparedStatement ps = queryExecutor . prepareStatementWithTimeout ( conn , sql )) {
17821784 int index = 1 ;
17831785 Set <String > parsedColumns = new HashSet <>(parsed .getColumns ());
17841786 for (String column : allColumns ) {
0 commit comments