I replaced the "localhost" with IP Address (Database server's public IP Address) in the jdbc Url then it worked.
jdbcUrl = "jdbc:oracle:thin:<user>@//localhost:1521/<Service Name>";
??
jdbcUrl = "jdbc:oracle:thin:<user>@//<Public IP Address>:1521/<Service Name>";