Search code examples
oracle-databasetomcatjvmjvm-arguments

How to add Oracle JVM arguments to Tomcat execution


I'm using an Oracle 11G version on my application, which is an Apache Tomcat server.

Some users have issues with some queries to the database when they use a specific time zone, like ETC/Universal for example. Oracle throws following exception:

ORA-01882: timezone region not found

I found a workaround for this problem. There is a specific argument that needs to be given to the JVM when it starts:

-Doracle.jdbc.timezoneAsRegion=false

I want to put this in the configuration of Tomcat. I need a Windows and a Linux solution. Where can I put this setting?


Solution

  • You can add the JVM arguments in the startup script of tomcat (usually catalina.bat or catalina.sh).

    For Windows (catalina.bat)

    set JAVA_OPTS="%JAVA_OPTS% -Doracle.jdbc.timezoneAsRegion=false"
    

    for linux (catalina.sh)

    JAVA_OPTS="$JAVA_OPTS -Doracle.jdbc.timezoneAsRegion=false"
    export JAVA_OPTS
    

    Also you can Update the file oracle/jdbc/defaultConnectionProperties.properties(i.e. inside your jar - ojdbc7.jar or classes12.jar) in whatever version of the library you are using to contain the line below:

    oracle.jdbc.timezoneAsRegion=false