Current Status

Actively playing with all possible backend services

27 October, 2011

Oracle database connection by Java - timezone error


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!!

No comments:

Some Popular Posts