You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级ojdbc8至18.3.0.0后Liquibase Gradle任务报ORA-01882错误求助

Fixing ORA-01882: timezone region not found with Liquibase Gradle Plugin and ojdbc8 18.3.0.0

I’ve run into this exact issue before when upgrading ojdbc8 to 18.x+ — the driver got stricter about timezone handling, which triggers that error when Liquibase connects. Here are a few reliable ways to add the required JVM parameters (-Duser.timezone or -Doracle.jdbc.timezoneAsRegion) to your Gradle Liquibase tasks:

1. Apply parameters to all Liquibase tasks

If you want every Liquibase task in your project to use these settings, add this block to your build.gradle:

tasks.withType(LiquibaseTask) {
    // Replace UTC with your actual required timezone (e.g., Asia/Shanghai)
    jvmArgs '-Duser.timezone=UTC', '-Doracle.jdbc.timezoneAsRegion=false'
}

This ensures any task of type LiquibaseTask (including your custom generated ones) gets the necessary JVM flags.

2. Add parameters to your custom generate tasks

If you only want to target the tasks created by your generate method, modify the task configuration directly:

def generate(taskName, taskDescription, generateCommand) {
    project.task(taskName, type: LiquibaseTask) {
        group = 'Liquibase'
        description = taskDescription
        inputs.property('databases', getRunList())
        inputs.dir liquibasePath
        outputs.dir sqlScriptsPath
        
        // Add the JVM parameters here
        jvmArgs '-Duser.timezone=UTC', '-Doracle.jdbc.timezoneAsRegion=false'
        
        doLast {
            new LiquibaseSqlCleanupTask(sqlScriptsPath).execute()
        }
    }
}

3. Temporary command-line override

If you need to test the fix without modifying your build script, pass the parameters via Gradle's JVM args when running the task:

./gradlew yourLiquibaseTaskName -Dorg.gradle.jvmargs="-Duser.timezone=UTC -Doracle.jdbc.timezoneAsRegion=false"

What do these parameters do?

  • -Duser.timezone=UTC: Sets the JVM's default timezone to a valid region (use the timezone ID relevant to your environment, like Europe/Warsaw if that's your region).
  • -Doracle.jdbc.timezoneAsRegion=false: Tells the ojdbc driver to use timezone offsets instead of region names, which avoids the "timezone region not found" error when the driver can't map the JVM's timezone to an Oracle-compatible region.

After applying any of these changes, re-run your Liquibase task — the ORA-01882 error should be resolved.

内容的提问来源于stack exchange,提问作者wojtek1902

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 03:55:39