Skip to content

Commit

Permalink
#207 Make ShedlockCompatible with PostgreSQL JDBC Driver 42.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-krecan-lt committed Mar 20, 2020
1 parent 57211b0 commit e29921e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Expand Up @@ -60,23 +60,23 @@ class JdbcTemplateStorageAccessor extends AbstractStorageAccessor {

@Override
public boolean insertRecord(@NotNull LockConfiguration lockConfiguration) {
String sql = "INSERT INTO " + tableName() + "(" + name() + ", " + lockUntil() + ", " + lockedAt() + ", " + lockedBy() + ") VALUES(?, ?, ?, ?)";
return transactionTemplate.execute(status -> {
try {
try {
String sql = "INSERT INTO " + tableName() + "(" + name() + ", " + lockUntil() + ", " + lockedAt() + ", " + lockedBy() + ") VALUES(?, ?, ?, ?)";
return transactionTemplate.execute(status -> {
int insertedRows = jdbcTemplate.update(sql, preparedStatement -> {
preparedStatement.setString(1, lockConfiguration.getName());
setTimestamp(preparedStatement, 2, lockConfiguration.getLockAtMostUntil());
setTimestamp(preparedStatement, 3, ClockProvider.now());
preparedStatement.setString(4, lockedByValue());
});
return insertedRows > 0;
} catch (DuplicateKeyException e) {
return false;
} catch (DataIntegrityViolationException e) {
logger.warn("Unexpected exception", e);
return false;
}
});
});
} catch (DuplicateKeyException e) {
return false;
} catch (DataIntegrityViolationException e) {
logger.warn("Unexpected exception", e);
return false;
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion providers/jdbc/shedlock-test-support-jdbc/pom.xml
Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212</version>
<version>42.2.11</version>
</dependency>

<dependency>
Expand Down

0 comments on commit e29921e

Please sign in to comment.