使用 Oracle Managed Driver Core 的 asp.net 核心 docker 容器.打开连接时抛出 ORA-00604 和 ORA-01882 [英] asp.net core docker container using Oracle Managed Driver Core. throws ORA-00604 and ORA-01882 when opening connection

查看:44
本文介绍了使用 Oracle Managed Driver Core 的 asp.net 核心 docker 容器.打开连接时抛出 ORA-00604 和 ORA-01882的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用 Oracle Managed Data Access for dotnet core (

Oracle.ManagedDataAccess.Client.OracleExceptionHResult=0x80004005消息=ORA-00604:递归 SQL 级别 1 发生错误ORA-01882: 未找到时区区域来源=适用于 .NET 的 Oracle 数据提供程序,托管驱动程序堆栈跟踪:在 OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, StringaffinityInstanceName, Boolean bForceMatch)在 OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)在 OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureStringsecuredPassword, SecureStringsecureProxyPassword, OracleConnection connRefForCriteria)在 Oracle.ManagedDataAccess.Client.OracleConnection.Open()在 WebApplication8.Controllers.HomeController.Index() 在 C:Usersmesource
eposWebApplication8WebApplication8ControllersHomeController.cs:line 22在 Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)在 Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)在 Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()

<小时>

更新:

我根据下面的@silent 回答做了一些额外的测试,发现了一些有趣的东西.如果我回滚到版本 2.12.0-beta3ODP.Net 核心 (https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core) 并删除了 TZ=America/Denver 环境变量,我可以毫无错误地打开连接.看起来像 2.18.3 中引入了一些东西,导致在 docker 容器内打开连接时对 TZ 环境变量的要求.

解决方案

我刚刚在类似的上下文中找到了解决方案(Oracle DB 11.2.0.4.0 和 NuGet 包 Oracle.ManagedDataAccess.Core 2.18.3):

将一个名为 TZ 的环境变量添加到您的容器并将值设置为您的时区,例如CET

这允许我打开连接.然后我也可以使用 this 解决方案中的部分来设置会话信息

this.Connection = new OracleConnection();this.Connection.ConnectionString = ...this.Connection.Open();OracleGlobalization info = this.Connection.GetSessionInfo();info.TimeZone = "America/New_York";this.Connection.SetSessionInfo(info);

I am receiving the below exception when trying to connect to an oracle database using the Oracle Managed Data Access for dotnet core (https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core/) from inside a docker container. I do not receive the exception outside of docker

Steps to Reproduce:

  1. Open VS 2017
  2. File > New > Project...
  3. Visual C# > .Net Core > ASP.Net Core Web Application
  4. Click Ok
  5. Select 'Web Application (Model-View-Controller)'
  6. uncheck 'Enabled Docker Support'
  7. uncheck 'Configure for HTTPS'
  8. Click Ok
  9. In Package Manager Console execute Install-Package Oracle.ManagedDataAccess.Core -Source nuget.org -Version 2.18.3
  10. Paste Code into HomeController.Index method
  11. Set breakpoint on line con.Open();
  12. Click Debug "IIS Express" button
  13. No exception is thrown when trying to open connection.
  14. Stop debugging
  15. Right Click on Web Project in Solution Explorer > Add > Docker Support
  16. Select 'Linux' Radio button and click OK
  17. Right Click on Web Project in Solution Explorer > Add > Container Orchestrator Support
  18. In the dropdown select 'Docker Compose' and click OK (depending on the version of Visual Studio 2017 installed this may differ)
  19. Click Yes if any popups are displayed asking to overwrite files
  20. Click Debug "Docker Compose" button
  21. An exception will be thrown when trying to open connection

Code:

var strm = new Oracle.ManagedDataAccess.Client.OracleConnectionStringBuilder();
strm.UserID = "<username>";
strm.Password = "<password>";
strm.DataSource = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=<db_host>)(PORT = 1521))) (CONNECT_DATA=(SERVICE_NAME=<service_name>)))";
using (var con = new Oracle.ManagedDataAccess.Client.OracleConnection(strm.ConnectionString))
{
     con.Open(); // Exception thrown here.
}

Exception:

Oracle.ManagedDataAccess.Client.OracleException
  HResult=0x80004005
  Message=ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
  Source=Oracle Data Provider for .NET, Managed Driver
  StackTrace:
   at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
   at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
   at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
   at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
   at WebApplication8.Controllers.HomeController.Index() in C:Usersmesource
eposWebApplication8WebApplication8ControllersHomeController.cs:line 22
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()


Update:

I was doing some additional testing based on @silent answer below and figured out something interesting. If I rolled back to version 2.12.0-beta3 of the ODP.Net core (https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core) and removed the TZ=America/Denver environment variable I am able to open a connection without error. It looks like something was introduced into 2.18.3 that's causing the requirement for the TZ environment variable when opening a connection inside a docker container.

解决方案

I just came to the solution in in similar context (Oracle DB 11.2.0.4.0 and NuGet package Oracle.ManagedDataAccess.Core 2.18.3):

Add an environment variable called TZ to your container and set the value to your timezone, e.g. CET

This allowed me to open the connection. Then I can also use the part from this solution to set the session info

this.Connection = new OracleConnection();
this.Connection.ConnectionString = ...
this.Connection.Open();
OracleGlobalization info = this.Connection.GetSessionInfo();
info.TimeZone = "America/New_York";
this.Connection.SetSessionInfo(info);

这篇关于使用 Oracle Managed Driver Core 的 asp.net 核心 docker 容器.打开连接时抛出 ORA-00604 和 ORA-01882的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆