DB2 10.5 for Linux, UNIX, and Windows

DB2Connection.ConnectionTimeout property

Gets or sets a value that determines the amount of time that an application waits for a connection.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

.NET Framework 2.0 3.0, 3.5, and 4.0 Syntax

[Visual Basic]
Overrides Public ReadOnly Property ConnectionTimeout As Integer
[C#]
public override int ConnectionTimeout {get;}
[C++]
public: __property virtual int get_ConnectionTimeout();
[JScript]
public function get ConnectionTimeout() : int;

Property value

The time duration (in seconds) to wait for a connection before client ends the connection attempt and reports an error. The default value is 0, which indicates that there is no time limit for the database connection to be established.

Exceptions

Exception type Condition
ArgumentException The value set is less than 0.

Remarks

The ConnectionTimeout value is enforced for a connection regardless of a high availability solution that is enabled. If a connection attempt fails within the time that is specified by the ConnectionTimeout value, control is returned to the application with an SQL30081N error. The error and control is returned to the application whether all alternative servers are tried or not.

Example

[Visual Basic, C#] The following example creates a DB2Connection by using the connection time keyword, and then checks the ConnectionTime .

[Visual Basic]
Public Sub CreateDB2Connection()
    Dim conn As New DB2Connection("Database=SAMPLE;Connect Timeout=30")
    conn.Open()
    Dim timeout As Integer = conn.ConnectionTimeout
End Sub

[C#]
public void CreateDB2Connection()
{
   DB2Connection conn = new DB2Connection("Database=SAMPLE;Connect Timeout=30");
   conn.Open();
   int timeout = conn.ConnectionTimeout;
}