Timezone region not found

Timezone region not found

我正在创建一个使用 Oracle 数据库的 C# MVC 项目。尝试连接数据库时,出现以下错误:

ORA-00604: error occurred at recursive SQL level 1

ORA-01882: timezone region not found.

关于 c#:Timezone region not found

当我尝试通过 SQL 开发人员连接时,它工作正常。有什么办法可以解决这个问题吗?

注意:我正在使用 IIS express 来测试


我在 Pivotal Cloud Foundry 上使用 ODP.NET for .NET Core 时遇到了同样的问题。核心问题是缺少时区信息。

通过为我的实例设置 "TZ" 环境变量添加了一个时区。这为我解决了这个问题。


实际上,这个错误是因为您使用的应用程序 Oracle 驱动程序和数据库的 Oracle 版本存在问题。

注意:请检查它们并为您的应用程序使用更新的 Oracle 版本。

ORA-01882: 未找到时区


在带有控制器的 .Net Core 3.1 API 中遇到了同样的问题。

在调试时出现错误,并解决了它在 \\\\\\\\Properties\\\\\\\\launchSettings.json 上添加 TZ:

"Docker": {

...

 "environmentVariables": {

   "TZ":"WET"

   }

}
 static void Main(string[] args)

 {

  Console.WriteLine("OracleGlobalization.TimeZone = {0}", Oracle.DataAccess.Client.OracleGlobalization.GetClientInfo().TimeZone);

  Console.WriteLine(String.Empty);



  Console.WriteLine("TimeZone.CurrentTimeZone.StandardName = {0}", TimeZone.CurrentTimeZone.StandardName);

  Console.WriteLine("TimeZone.CurrentTimeZone.DaylightName = {0}", TimeZone.CurrentTimeZone.DaylightName);

  Console.WriteLine(String.Empty);



  Console.WriteLine("TimeZoneInfo.Local.DisplayName = {0}", TimeZoneInfo.Local.DisplayName);

  Console.WriteLine("TimeZoneInfo.Local.Id = {0}", TimeZoneInfo.Local.Id);

  Console.WriteLine("TimeZoneInfo.Local.StandardName = {0}", TimeZoneInfo.Local.StandardName);

  Console.WriteLine("TimeZoneInfo.Local.DaylightName = {0}", TimeZoneInfo.Local.DaylightName);

  Console.WriteLine(String.Empty);



  var str = new Oracle.DataAccess.Client.OracleConnectionStringBuilder();

  str.UserID ="<username>";

  str.Password ="<password>";

  str.DataSource ="<database name>";

  using ( var con = new Oracle.DataAccess.Client.OracleConnection(str.ConnectionString) ) {

    con.Open();

    Console.WriteLine("Oracle.DataAccess: OracleConnection -> SessionInfo.TimeZone = {0}", con.GetSessionInfo().TimeZone);

    Console.WriteLine("Oracle.DataAccess: Version = {0}", FileVersionInfo.GetVersionInfo(con.GetType().Assembly.Location).FileVersion.ToString());



    var tz = new Oracle.DataAccess.Client.OracleCommand("SELECT SESSIONTIMEZONE FROM dual", con).ExecuteScalar();

    Console.WriteLine("Oracle.DataAccess: SESSIONTIMEZONE = {0}", tz.ToString());

    con.Close();

  }

  Console.WriteLine(String.Empty);



  var strm = new Oracle.ManagedDataAccess.Client.OracleConnectionStringBuilder();

  str.UserID ="<username>";

  str.Password ="<password>";

  str.DataSource ="<database name>";

  using ( var con = new Oracle.ManagedDataAccess.Client.OracleConnection(str.ConnectionString) ) {

    con.Open();

    Console.WriteLine("Oracle.ManagedDataAccess: OracleConnection -> SessionInfo.TimeZone = {0}", con.GetSessionInfo().TimeZone);

    Console.WriteLine("Oracle.ManagedDataAccess: Version = {0}", FileVersionInfo.GetVersionInfo(con.GetType().Assembly.Location).FileVersion.ToString());



    var tz = new Oracle.ManagedDataAccess.Client.OracleCommand("SELECT SESSIONTIMEZONE FROM dual", con).ExecuteScalar();

    Console.WriteLine("Oracle.ManagedDataAccess: SESSIONTIMEZONE = {0}", tz.ToString());

    con.Close();

  }

 }
AddVMOption -Duser.timezone="+02:00"

此代码不提供答案,但它可能有助于找到您的问题。

代码太大,无法评论。

请执行这个程序。输出是什么?哪里出错了?

"Docker": {

...

 "environmentVariables": {

   "TZ":"WET"

   }

}
 static void Main(string[] args)

 {

  Console.WriteLine("OracleGlobalization.TimeZone = {0}", Oracle.DataAccess.Client.OracleGlobalization.GetClientInfo().TimeZone);

  Console.WriteLine(String.Empty);



  Console.WriteLine("TimeZone.CurrentTimeZone.StandardName = {0}", TimeZone.CurrentTimeZone.StandardName);

  Console.WriteLine("TimeZone.CurrentTimeZone.DaylightName = {0}", TimeZone.CurrentTimeZone.DaylightName);

  Console.WriteLine(String.Empty);



  Console.WriteLine("TimeZoneInfo.Local.DisplayName = {0}", TimeZoneInfo.Local.DisplayName);

  Console.WriteLine("TimeZoneInfo.Local.Id = {0}", TimeZoneInfo.Local.Id);

  Console.WriteLine("TimeZoneInfo.Local.StandardName = {0}", TimeZoneInfo.Local.StandardName);

  Console.WriteLine("TimeZoneInfo.Local.DaylightName = {0}", TimeZoneInfo.Local.DaylightName);

  Console.WriteLine(String.Empty);



  var str = new Oracle.DataAccess.Client.OracleConnectionStringBuilder();

  str.UserID ="<username>";

  str.Password ="<password>";

  str.DataSource ="<database name>";

  using ( var con = new Oracle.DataAccess.Client.OracleConnection(str.ConnectionString) ) {

    con.Open();

    Console.WriteLine("Oracle.DataAccess: OracleConnection -> SessionInfo.TimeZone = {0}", con.GetSessionInfo().TimeZone);

    Console.WriteLine("Oracle.DataAccess: Version = {0}", FileVersionInfo.GetVersionInfo(con.GetType().Assembly.Location).FileVersion.ToString());



    var tz = new Oracle.DataAccess.Client.OracleCommand("SELECT SESSIONTIMEZONE FROM dual", con).ExecuteScalar();

    Console.WriteLine("Oracle.DataAccess: SESSIONTIMEZONE = {0}", tz.ToString());

    con.Close();

  }

  Console.WriteLine(String.Empty);



  var strm = new Oracle.ManagedDataAccess.Client.OracleConnectionStringBuilder();

  str.UserID ="<username>";

  str.Password ="<password>";

  str.DataSource ="<database name>";

  using ( var con = new Oracle.ManagedDataAccess.Client.OracleConnection(str.ConnectionString) ) {

    con.Open();

    Console.WriteLine("Oracle.ManagedDataAccess: OracleConnection -> SessionInfo.TimeZone = {0}", con.GetSessionInfo().TimeZone);

    Console.WriteLine("Oracle.ManagedDataAccess: Version = {0}", FileVersionInfo.GetVersionInfo(con.GetType().Assembly.Location).FileVersion.ToString());



    var tz = new Oracle.ManagedDataAccess.Client.OracleCommand("SELECT SESSIONTIMEZONE FROM dual", con).ExecuteScalar();

    Console.WriteLine("Oracle.ManagedDataAccess: SESSIONTIMEZONE = {0}", tz.ToString());

    con.Close();

  }

 }
AddVMOption -Duser.timezone="+02:00"

更新

根据您的个人资料,您在斯里兰卡。斯里兰卡的时区似乎相当"不稳定",请参阅 IANA 时区数据库中的文本:

Sri Lanka

From Paul Eggert (2013-02-21):

Milne says"Madras mean time use from May 1, 1898. Prior to this Colombo

mean time, 5h. 4m. 21.9s. F., was used." But 5:04:21.9 differs considerably

from Colombo's meridian 5:19:24, so for now ignore Milne and stick with

Shanks and Pottenger.

From Paul Eggert (1996-09-03):

"Sri Lanka advances clock by an hour to avoid blackout"

(http://www.virtual-pc.com/lankaweb/news/items/240596-2.html, 1996-05-24,

no longer available as of 1999-08-17)

reported"the country's standard time will be put forward by one hour at

midnight Friday (1830 GMT) 'in the light of the present power crisis'."

From Dharmasiri Senanayake, Sri Lanka Media Minister (1996-10-24), as quoted

by Shamindra in Daily News - Hot News Section

(1996-10-26):

With effect from 12.30 a.m. on 26th October 1996

Sri Lanka will be six (06) hours ahead of GMT.

From Jesper N??rgaard Welen (2006-04-14), quoting Sri Lanka News Online

http://news.sinhalaya.com/wmview.php?ArtID=11002 (2006-04-13):

0030 hrs on April 15, 2006 (midnight of April 14, 2006 +30 minutes)

at present, become 2400 hours of April 14, 2006 (midnight of April 14, 2006).

From Peter Apps and Ranga Sirila of Reuters (2006-04-12) in:

http://today.reuters.co.uk/news/newsArticle.aspx?type=scienceNews&storyID=2006-04-12T172228Z_01_COL295762_RTRIDST_0_SCIENCE-SRILANKA-TIME-DC.XML

[The Tamil Tigers] never accepted the original 1996 time change and simply

kept their clocks set five and a half hours ahead of Greenwich Mean

Time (GMT), in line with neighbor India.

From Paul Eggert (2006-04-18):

People who live in regions under Tamil control can use [TZ='Asia/Kolkata'],

as that zone has agreed with the Tamil areas since our cutoff date of 1970.

From Sadika Sumanapala (2016-10-19):

According to http://www.sltime.org (maintained by Measurement Units,

Standards & Services Department, Sri Lanka) abbreviation for Sri Lanka

standard time is SLST.

From Paul Eggert (2016-10-18):

"SLST" seems to be reasonably recent and rarely-used outside time

zone nerd sources. I searched Google News and found three uses of

it in the International Business Times of India in February and

March of this year when discussing cricket match times, but nothing

since then (though there has been a lot of cricket) and nothing in

other English-language news sources. Our old abbreviation"LKT" is

even worse. For now, let's use a numeric abbreviation; we can

switch to"SLST" if it catches on.

我假设您的数据库无法识别您计算机当前的本地时区。可能有三种可能的解决方案:

  • 将您的计算机区域设置更改为更稳定的设置,例如印度
  • 使用最新版本的时区文件更新数据库,请参阅使用时区数据升级时区文件和时间戳
  • 如果您使用 ODP.NET 非托管驱动程序 Oracle.DataAccess.dll(很遗憾您没有告诉我们),您可以将 ORA_SDTZ 环境变量或注册表项 HKEY_LOCAL_MACHINE\\SOFTWARE\\ORACLE\\KEY_<Oracle home name>\\ORA_SDTZ / HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ORACLE\\KEY_<Oracle home name>\\ORA_SDTZ 设置为所需的时区值。请注意,ODP.NET 托管驱动程序不会读取此注册表值。

根据这个和这个:

C:\\Program Files\\datamodeler 3\\datamodeler\\bin\\datamodeler.conf 中添加

"Docker": {

...

 "environmentVariables": {

   "TZ":"WET"

   }

}
 static void Main(string[] args)

 {

  Console.WriteLine("OracleGlobalization.TimeZone = {0}", Oracle.DataAccess.Client.OracleGlobalization.GetClientInfo().TimeZone);

  Console.WriteLine(String.Empty);



  Console.WriteLine("TimeZone.CurrentTimeZone.StandardName = {0}", TimeZone.CurrentTimeZone.StandardName);

  Console.WriteLine("TimeZone.CurrentTimeZone.DaylightName = {0}", TimeZone.CurrentTimeZone.DaylightName);

  Console.WriteLine(String.Empty);



  Console.WriteLine("TimeZoneInfo.Local.DisplayName = {0}", TimeZoneInfo.Local.DisplayName);

  Console.WriteLine("TimeZoneInfo.Local.Id = {0}", TimeZoneInfo.Local.Id);

  Console.WriteLine("TimeZoneInfo.Local.StandardName = {0}", TimeZoneInfo.Local.StandardName);

  Console.WriteLine("TimeZoneInfo.Local.DaylightName = {0}", TimeZoneInfo.Local.DaylightName);

  Console.WriteLine(String.Empty);



  var str = new Oracle.DataAccess.Client.OracleConnectionStringBuilder();

  str.UserID ="<username>";

  str.Password ="<password>";

  str.DataSource ="<database name>";

  using ( var con = new Oracle.DataAccess.Client.OracleConnection(str.ConnectionString) ) {

    con.Open();

    Console.WriteLine("Oracle.DataAccess: OracleConnection -> SessionInfo.TimeZone = {0}", con.GetSessionInfo().TimeZone);

    Console.WriteLine("Oracle.DataAccess: Version = {0}", FileVersionInfo.GetVersionInfo(con.GetType().Assembly.Location).FileVersion.ToString());



    var tz = new Oracle.DataAccess.Client.OracleCommand("SELECT SESSIONTIMEZONE FROM dual", con).ExecuteScalar();

    Console.WriteLine("Oracle.DataAccess: SESSIONTIMEZONE = {0}", tz.ToString());

    con.Close();

  }

  Console.WriteLine(String.Empty);



  var strm = new Oracle.ManagedDataAccess.Client.OracleConnectionStringBuilder();

  str.UserID ="<username>";

  str.Password ="<password>";

  str.DataSource ="<database name>";

  using ( var con = new Oracle.ManagedDataAccess.Client.OracleConnection(str.ConnectionString) ) {

    con.Open();

    Console.WriteLine("Oracle.ManagedDataAccess: OracleConnection -> SessionInfo.TimeZone = {0}", con.GetSessionInfo().TimeZone);

    Console.WriteLine("Oracle.ManagedDataAccess: Version = {0}", FileVersionInfo.GetVersionInfo(con.GetType().Assembly.Location).FileVersion.ToString());



    var tz = new Oracle.ManagedDataAccess.Client.OracleCommand("SELECT SESSIONTIMEZONE FROM dual", con).ExecuteScalar();

    Console.WriteLine("Oracle.ManagedDataAccess: SESSIONTIMEZONE = {0}", tz.ToString());

    con.Close();

  }

 }
AddVMOption -Duser.timezone="+02:00"

相关推荐

  • Spring部署设置openshift

    Springdeploymentsettingsopenshift我有一个问题让我抓狂了三天。我根据OpenShift帐户上的教程部署了spring-eap6-quickstart代码。我已配置调试选项,并且已将Eclipse工作区与OpehShift服务器同步-服务器上的一切工作正常,但在Eclipse中出现无法消除的错误。我有这个错误:cvc-complex-type.2.4.a:Invali…
    2025-04-161
  • 检查Java中正则表达式中模式的第n次出现

    CheckfornthoccurrenceofpatterninregularexpressioninJava本问题已经有最佳答案,请猛点这里访问。我想使用Java正则表达式检查输入字符串中特定模式的第n次出现。你能建议怎么做吗?这应该可以工作:MatchResultfindNthOccurance(intn,Patternp,CharSequencesrc){Matcherm=p.matcher…
    2025-04-161
  • 如何让 JTable 停留在已编辑的单元格上

    HowtohaveJTablestayingontheeditedcell如果有人编辑JTable的单元格内容并按Enter,则内容会被修改并且表格选择会移动到下一行。是否可以禁止JTable在单元格编辑后转到下一行?原因是我的程序使用ListSelectionListener在单元格选择上同步了其他一些小部件,并且我不想在编辑当前单元格后选择下一行。Enter的默认绑定是名为selectNext…
    2025-04-161
  • Weblogic 12c 部署

    Weblogic12cdeploy我正在尝试将我的应用程序从Tomcat迁移到Weblogic12.2.1.3.0。我能够毫无错误地部署应用程序,但我遇到了与持久性提供程序相关的运行时错误。这是堆栈跟踪:javax.validation.ValidationException:CalltoTraversableResolver.isReachable()threwanexceptionatorg.…
    2025-04-161
  • Resteasy Content-Type 默认值

    ResteasyContent-Typedefaults我正在使用Resteasy编写一个可以返回JSON和XML的应用程序,但可以选择默认为XML。这是我的方法:@GET@Path("/content")@Produces({MediaType.APPLICATION_XML,MediaType.APPLICATION_JSON})publicStringcontentListRequestXm…
    2025-04-161
  • 代码不会停止运行,在 Java 中

    thecodedoesn'tstoprunning,inJava我正在用Java解决项目Euler中的问题10,即"Thesumoftheprimesbelow10is2+3+5+7=17.Findthesumofalltheprimesbelowtwomillion."我的代码是packageprojecteuler_1;importjava.math.BigInteger;importjava…
    2025-04-161
  • Out of memory java heap space

    Outofmemoryjavaheapspace我正在尝试将大量文件从服务器发送到多个客户端。当我尝试发送大小为700mb的文件时,它显示了"OutOfMemoryjavaheapspace"错误。我正在使用Netbeans7.1.2版本。我还在属性中尝试了VMoption。但仍然发生同样的错误。我认为阅读整个文件存在一些问题。下面的代码最多可用于300mb。请给我一些建议。提前致谢publicc…
    2025-04-161
  • Log4j 记录到共享日志文件

    Log4jLoggingtoaSharedLogFile有没有办法将log4j日志记录事件写入也被其他应用程序写入的日志文件。其他应用程序可以是非Java应用程序。有什么缺点?锁定问题?格式化?Log4j有一个SocketAppender,它将向服务发送事件,您可以自己实现或使用与Log4j捆绑的简单实现。它还支持syslogd和Windows事件日志,这对于尝试将日志输出与来自非Java应用程序…
    2025-04-161