Oracle 11g 客户端连接到 10g 和 11g 数据库

发布于 2025-01-07 12:40:01 字数 179 浏览 1 评论 0原文

我看过一些帖子说 Oracle 11g 客户端(适用于 Windows)可以在 9.2 及更高版本的数据库上正常工作。但是,如果客户端有时连接到 11g,有时连接到 10g 数据库,它还能工作吗?我的问题是:连接 10g 和 11g 数据库时是否需要进行不同的配置?

有些人向我介绍了 GAC 的政策。

谢谢 !

I've seen a few post that says Oracle 11g Client (for Windows) works fine with databases up to 9.2. But if the client sometimes connect to 11g and sometimes to 10g databases, is it still working ? My question is : Is there anything to configure differently when connecting to 10g and 11g databases ?

Some people have told me about policies in the GAC.

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深府石板幽径 2025-01-14 12:40:02

使用较新的客户端驱动程序连接到较旧的 Oracle 数据库通常没有问题,例如使用 12g 客户端连接到 10g 或 11g 数据库。答案的其余部分属于技术问题,如果执行程序的计算机上(可能)已经安装了 Oracle 客户端,则 .Net 程序中可能会出现这些问题。


2014 年更新:

与此同时,Oracle 发布了适用于 Oracle 数据库的托管 .Net 驱动程序。因此,首选方法应该是仅提供托管驱动程序,而不依赖于本地配置,而不是安装本地 Oracle 客户端或随应用程序提供即时客户端。这样您就可以轻松安装客户端、GAC、Oracle 数据库版本等。您可以从Oracle 网站下载托管驱动程序。


如果您无法使用托管驱动程序,仍然需要之前的答案:

如果您不知道客户端工作站上是否安装了 Oracle 客户端,就会出现问题。如果您正在谈论 GAC,我假设您不知道是否安装了 Oracle 客户端,如果安装了,它是什么版本

如果您不想依赖已安装的 Oracle 客户端,您可以随 .Net 应用程序一起提供 Oracle Instant Client。例如,您可以下载 ODAC 11.2 Release 4 (11.2.0.3.0 )与 Oracle Developer Tools for Visual Studio,它为您的开发人员工作站提供 Oracle 客户端安装(Visual Studio 支持数据集开发和 EntityFramework)以及开发所需的所有文件即时客户端。

对于即时客户端,您需要以下文件(在 ODAC 安装的子文件夹中搜索它们):

  • oci.dll
  • ociw32.dll
  • Oracle.DataAccess.dll
  • orannzsbb11.dll
  • oraociicus11.dll(如果您使用英语,否则相应的 . dll)
  • OraOpd11w.dll
  • tnsnames.ora(如果需要)

此外,还需要 Windows 目录中的以下 .dll 文件:

  • mfc71.dll
  • msvcr71.dll

只需将所有文件复制到应用程序的工作目录(.exe 文件所在的位置)即可。

现在它如何属于 GAC?

如果客户端计算机上安装了 Oracle 客户端,那么 GAC 中也会有一个 Oracle.DataAccess.dll。也有可能安装了一个策略,其中规定了类似以下内容:独立于程序引用的 Oracle.DataAccess.dll,Oracle.DataAccess.dll 版本来自您的 GAC 将始终被使用。如果您安装我上面链接的 ODAC,您会在下面找到该文件

C:\Windows\Microsoft.NET\Assembly\GAC_32\Policy.4.112.Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342

结果是,如果您尝试加载 Oracle.DataAccess,您的 .Net 应用程序总是会引发异常.dll(带有类似“提供程序不兼容...”的错误消息),如果客户端计算机具有其他版本的 Oracle 客户端比您在应用程序中引用的版本安装了 11 个版本。

要解决这个问题,您可以配置 app.conf,以便忽略发布者策略并始终加载您的版本:

<configuration>
...
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342" />
        <publisherPolicy apply="no" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

There is commonly no problem to connect to an older Oracle database with a newer client driver, e.g. to connect to a 10g or 11g database with a 12g Client. The rest of the answer belongs to technical problems which can occur in your .Net program in the case that an Oracle Client is (maybe) already installed on the computer executing your program.


Update 2014:

In the meanwhile Oracle has released a managed .Net driver for the Oracle database. So instead of installing a local Oracle Client or delivering an Instant Client along with your app, the preferred way should be to deliver just the managed driver without any dependencies to local configurations. Then you have no trouble with installed clients, the GAC, the Oracle database version and so on. You can download the managed driver from the Oracle website.


Previous answer, still needed if you can't use the managed driver:

The problems begin if you don't know if there is an Oracle client installed on your client workstations. If you are talking about GAC I assume, you don't know if an Oracle Client is installed and if so, which version it is.

If you don't want to rely on an installed Oracle Client, you can deliver an Oracle Instant Client with your .Net application. For example you can download ODAC 11.2 Release 4 (11.2.0.3.0) with Oracle Developer Tools for Visual Studio, which gives you an Oracle Client installation for your developer workstation (with Visual Studio support for DataSet development and EntityFramework) as well as all files needed for an instant client.

For an instant client you need the following files (search them in the subfolders of your ODAC installation):

  • oci.dll
  • ociw32.dll
  • Oracle.DataAccess.dll
  • orannzsbb11.dll
  • oraociicus11.dll (if you are using english language, else the corresponding .dll)
  • OraOpd11w.dll
  • tnsnames.ora (if you need it)

In addition the following .dll files are needed from your Windows directory:

  • mfc71.dll
  • msvcr71.dll

Just copy all that files in the working directory of your application (where the .exe file is).

Now how belongs that to the GAC?

If an Oracle Client is installed on the client machine there is also an Oracle.DataAccess.dll in the GAC. Also it is possible, that a policy was installed which states something like: Independant of the Oracle.DataAccess.dll your program is referencing, the Oracle.DataAccess.dll version from your GAC shall always be used. If you install the ODAC I linked above, you find that file under

C:\Windows\Microsoft.NET\assembly\GAC_32\Policy.4.112.Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342

The result is that your .Net application always throws an exception if you are trying to load the Oracle.DataAccess.dll (with an error message like "The provider is not compatible..."), if the client machine has another version of Oracle Client 11 installed than the one you are referencing in your application.

To solve that, you can configure your app.conf so that the publisher policy will be ignored and always your version is loaded:

<configuration>
...
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342" />
        <publisherPolicy apply="no" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
失与倦" 2025-01-14 12:40:02

我在使用 JAVA 或 .Net 时没有遇到任何问题。事实上,Oracle 说它完全没问题:

该版本包含 Oracle 数据库客户端 11.2.0.3,它可以
访问 Oracle 数据库 9.2 及更高版本。 Oracle 支持实体
Microsoft Visual Studio 2010 和 .NET 的框架和 LINQ
框架 4,包括实体框架 4.1 和 4.2。代码优先不是
此版本支持。

显然,您希望在连接到每个进程时测试相同的进程并通过您自己的测试进行验证,但我认为您会没事的。

I have not had any problems doing this with JAVA or .Net. In fact, Oracle says it's perfectly fine:

The release incorporates Oracle Database client 11.2.0.3, which can
access Oracle Database 9.2 and higher. Oracle supports Entity
Framework and LINQ with Microsoft Visual Studio 2010 and .NET
Framework 4, including Entity Framework 4.1 and 4.2. Code First is not
supported in this release.

Obviously you would want to test the same processes while connect to each one and verify through your own tests, but I think you will be fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文