none
Establish Connection with DB2 UDB Database RRS feed

  • Question


  • Whenever I try to establish connection with  DB2 UDB database in .Net 2.0, it is taking 1-2 mins to open the connection. I'm using DB2Connecton in C# for this purpose.

    sConnectionString_DB2 = "Server=DB2ServerName:PORT;Database=DATABASENAME;UID=USERNAME;PWD=PASSWORD;";

    if (objDB2Con.State == ConnectionState.Closed)
    {
     objDB2Con.ConnectionString = sConnectionString_DB2;
     objDB2Con.Open();
    }

    Thursday, August 25, 2011 6:31 PM

Answers

  • Hi do you have a remote DB2 Server? If you use your localhost as a server, I think it shouldn't appear this issue.

    And you can use a connection pool to manage your connection, if you have already used one, try to make its size larger. The connection pool size is too little is another reason of your issue.

    Because you might not set the timeout, the default setting is 0, that means if your connection pool is full, you are always waiting for the release one. So it will take so much time.

    I hope this can help you.

     

    have a nice day,

     


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, August 30, 2011 8:18 AM
    Moderator

All replies

  • Hello Gurdarshan,

    Thanks for your post.

    What's your question? And do you have any errors or exceptions using the above connection string? If so, please tell us.

    The following is the standard connection string of DB2 .net data provider:

    "Server=myAddress:myPortNumber;Database=myDataBase;UID=myUsername;PWD=myPassword; "

    Note that: The Server key value syntax is a server name / ip address and an optional port number (note the : in between).

    If you have a connection pool, here is an example:

    "Server=myAddress:myPortNumber;Database=myDataBase;UID=myUsername;PWD=myPassword;Max Pool Size=100;Min Pool Size=10;"

    I hope this can help you.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Monday, August 29, 2011 7:23 AM
    Moderator
  • my concern is whenever I open my DB2 connection using DB2Connection, it is taking 2-3 mins to establish connection with DB2 Server
    Monday, August 29, 2011 8:33 PM
  • Hi do you have a remote DB2 Server? If you use your localhost as a server, I think it shouldn't appear this issue.

    And you can use a connection pool to manage your connection, if you have already used one, try to make its size larger. The connection pool size is too little is another reason of your issue.

    Because you might not set the timeout, the default setting is 0, that means if your connection pool is full, you are always waiting for the release one. So it will take so much time.

    I hope this can help you.

     

    have a nice day,

     


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, August 30, 2011 8:18 AM
    Moderator