ORA-01882: timezone region not found

In a plain a SQL-Developer installation under Windows go to directory

C:\Program Files\sqldeveloper\sqldeveloper\bin

and add

AddVMOption -Duser.timezone=CET

to file sqldeveloper.conf.


Error I got :

Error from db_connection.java -->> java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1 ORA-01882: timezone region not found

ORA-00604: error occurred at recursive SQL level 1ORA-01882: timezone region not found

Prev code:

 public Connection getOracle() throws Exception {
     Connection conn = null;
     Class.forName("oracle.jdbc.driver.OracleDriver");
     conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:tap", "username", "pw");
     return conn;
}

new Code:

 public Connection getOracle() throws Exception {
     TimeZone timeZone = TimeZone.getTimeZone("Asia/Kolkata");
     TimeZone.setDefault(timeZone);
     Connection conn = null;
     Class.forName("oracle.jdbc.driver.OracleDriver");
     conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:tap", "username", "pw");
     return conn;
}

now it is working!!


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

oracle.jdbc.timezoneAsRegion=false

You may also try to check the version of the Oracle jdbc driver and Oracle database. Just today I had this issue when using ojdbc6.jar (version 11.2.0.3.0) to connect to an Oracle 9.2.0.4.0 server. Replacing it with ojdbc6.jar version 11.1.0.7.0 solved the issue.

I also managed to make ojdbc6.jar version 11.2.0.3.0 connect without error, by adding oracle.jdbc.timezoneAsRegion=false in file oracle/jdbc/defaultConnectionProperties.properties (inside the jar). Found this solution here (broken link)

Then, one can add -Doracle.jdbc.timezoneAsRegion=false to the command line, or AddVMOption -Doracle.jdbc.timezoneAsRegion=false in config files that use this notation.

You can also do this programmatically, e.g. with System.setProperty.

In some cases you can add the environment variable on a per-connection basis if that's allowed (SQL Developer allows this in the "Advanced" connection properties; I verified it to work when connecting to a database that doesn't have the problem and using a database link to a database which has).