【发布时间】:2020-07-15 13:21:29
【问题描述】:
我想使用 .NET Core 3.1 从 Windows 客户端计算机连接到 IBM i 7.2 服务器上的 DB2 数据库。我通过 NuGet 安装了 IBM.Data.DB2.Core,但它总是抛出这个神秘的异常:
IBM.Data.DB2.Core.DB2Exception
HResult=0x80004005
Message=External component has thrown an exception.
Source=IBM.Data.DB2.Core
StackTrace:
at IBM.Data.DB2.Core.DB2ConnPool.Open(DB2Connection connection, String& szConnectionString, DB2ConnSettings& ppSettings, Object& ppConn)
at IBM.Data.DB2.Core.DB2Connection.Open()
at Dapper.SqlMapper.<QueryImpl>d__140`1.MoveNext() in /_/Dapper/SqlMapper.cs:line 1079
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in /_/Dapper/SqlMapper.cs:line 721
at Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in /_/Dapper/SqlMapper.cs:line 648
at SqlPerformanceTesting.Program.<Main>d__0.MoveNext() in C:\Users\mmarchese\Desktop\SqlPerformanceTesting\SqlPerformanceTesting\Program.cs:line 54
我认为我需要先在我的 Windows 客户端机器上安装不同的驱动程序/软件。现在,我已经安装了“IBM I Access Client Solutions”,但也许我需要其他东西,例如“IBM 数据服务器驱动程序”?这似乎需要许可证?我是否还需要在 IBM 服务器上安装一些东西才能使用它?有人可以为我拼写出来或给我指一个好的指南吗?我自己找不到太多东西。比如,“以下是一般步骤:”
- 在 Windows 客户端上安装软件 A
- 在 IBM i 服务器上安装软件 B
- 在 Windows 客户端上安装 IBM.Data.DB2.Core
- 执行过程 C 来配置 Windows 客户端
- 执行过程 D 来配置 IBM 服务器
更新:
如果我指定了错误的连接字符串,我会得到一个不同的错误。由于 IBM.Data.DB2.Core 包含一个用于构建有效连接字符串的类,我假设我的连接字符串没问题:
var connStringBld = new DB2ConnectionStringBuilder()
{
Database = "myDb",
UserID = "myUser",
Password = "myPassword",
Server = "myIp"
};
Console.WriteLine(connStringBld.ConnectionString);
// Database=myDb;User ID=myUser;Password=myPassword;Server=myIp
【问题讨论】:
-
奇怪的巧合。今天早上有人在 Android 上有相同的 0x80004005。可能是找不到文件。检查文件资源管理器并从运行代码的机器上查看 dB2 数据库。
-
@jdweng 是的,我认为一个文件(或许多文件)丢失了,但我不知道是哪个文件或如何解决它。我想我一定是跳过了必需的驱动程序安装。
-
可能是连接字符串。
-
你为什么不使用“IBM.Data.DB2.iSeries”?请参阅 ibm.com/support/pages/ibm-i-access-windows-net-data-provider 并获取“IBM DB2 for i .NET Provider Technical Reference”,它是 IBM i Access for Windows Programmer's Toolkit 的一部分,这是 IBM i Access for Windows 产品的可选安装功能。
-
@jdweng 我不认为这是连接字符串。有关更多信息,请参阅我的更新。
标签: c# .net-core db2 ibm-midrange