'Scheduled annotation with utc zone is giving error
@SchedulerLock(name = "DynamicLock", lockAtLeastFor = "PT1M", lockAtMostFor = "PT2M")
@Scheduled(cron = "0 56 14 1/1 * ?", zone = "UTC")
public void method() {
{....}
}
my scheduler lock uses UTC timezone so for @Scheduled cron expression I am using utc timezone. If I use like this I am getting below error.
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO shedlock(name, lock_until, locked_at, locked_by) VALUES(?, timezone('utc', CURRENT_TIMESTAMP) + cast(? as interval), timezone('utc', CURRENT_TIMESTAMP), ?) ON CONFLICT (name) DO UPDATE SET lock_until = timezone('utc', CURRENT_TIMESTAMP) + cast(? as interval), locked_at = timezone('utc', CURRENT_TIMESTAMP), locked_by = ? WHERE shedlock.name = ? AND shedlock.lock_until <= timezone('utc', CURRENT_TIMESTAMP)]; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying <= timestamp without time zone
Please help on resolving this error
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
