gpt4 book ai didi

.net - IBM.Data.DB2.DB2Exception : ERROR [08001] [IBM] SQL30081N A communication error has been detected.

转载 作者:行者123 更新时间:2023-12-05 05:28:23 26 4
gpt4 key购买 nike

我的应用程序通过 .net 提供程序 (FP5) 与 IBM DB2 配合使用。当我离开应用程序很长时间,然后尝试从数据库中获取任何内容时 - 我收到以下错误:

---> IBM.Data.DB2.DB2Exception: ERROR [08001] [IBM] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "SERVER_IP". Communication function detecting the error: "recv". Protocol specific error code(s): "10054", "*", "0". SQLSTATE=08001

我使用 Entity Framework 与数据库通信,在崩溃操作之前我总是有以下代码:

using (EEntities db =  EntitiesFactory.CreateEEntity())
{
// ..some operations
}

哪里:

public static EEntities CreateEEntity()
{
if (!string.IsNullOrEmpty(GlobalCommon.DBConnectionString))
return CreateEEntity(GlobalCommon.DBConnectionString);
return new EEntities();
}

public static EEntities CreateEEntity(string connectionString)
{
return new EEntities(connectionString);
}

和:

public static string DBConnectionString
{
get
{
if (!string.IsNullOrWhiteSpace(_DBConnectionString))
return _DBConnectionString;

string providerConnectionString = "Database=" +
Settings.Default.DBDatabase + ";User ID=" +
DBUserID + ";Password=" +
DBPassword + ";Server=" +
DBServer + ";Max Pool Size=150;Min Pool Size=15;Connection Lifetime=80;Pooling=true;";


// Initialize the EntityConnectionStringBuilder.
EntityConnectionStringBuilder entityBuilder =
new EntityConnectionStringBuilder();

//Set the provider name.
entityBuilder.Provider = "IBM.Data.DB2";

// Set the provider-specific connection string.
entityBuilder.ProviderConnectionString = providerConnectionString;

// Set the Metadata location.
entityBuilder.Metadata = @"res://*/DAL.DBModel.csdl|
res://*/DAL.DBModel.ssdl|
res://*/DAL.DBModel.msl";
_DBConnectionString = entityBuilder.ToString();

return _DBConnectionString;
}
set
{
_DBConnectionString = value;
}
}

所以我认为如果连接终止,我总是会重新连接以下几行。
池或连接生命周期会不会有问题?..

最佳答案

此错误通常意味着您的连接已被 DBA 终止,或者存在一个网络故障中断了与您的应用程序的连接。

如果出现此错误,只需重新连接到数据库即可。

关于.net - IBM.Data.DB2.DB2Exception : ERROR [08001] [IBM] SQL30081N A communication error has been detected.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11202465/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com