0x49D1
0x49D1

Reputation: 8704

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

My application works with IBM DB2 via their .net provider(FP5). When i left application for a long time and after that try to get anything from database- i get the following error:

---> 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

I use entity framework to communicate with the database and before the crashing operations i always have the following code:

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

where:

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);
        }

and:

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;
            }
        }

so that i think with following lines i always do reconnect if the connection was terminated.
Can there be a problem with pooling or connection lifetime?..

Upvotes: 4

Views: 11240

Answers (1)

Ian Bjorhovde
Ian Bjorhovde

Reputation: 11042

This error typically means that your connection has been killed by the DBA, or that there was a network blip that broke the connection from your application.

If you get this error, just reconnect to the database.

Upvotes: 2

Related Questions