ClientInteractive Property
Determines the inactivity timeout before the server breaks the connection.
public bool ClientInteractive {get; set;}
'Declaration
Public Property ClientInteractive As Boolean
Property Value
If
true, the server breaks the connection after number of seconds specified in
interactive_timeout sever variable, otherwise
wait_timeout is used. The default value is
false.
The following example demonstrates usage of this property.
static void Main(string[] args) {
MySqlConnectionStringBuilder connStrBuilder = new MySqlConnectionStringBuilder();
connStrBuilder.UserId = "root";
connStrBuilder.Password = "";
connStrBuilder.Host = "localhost";
connStrBuilder.Port = 3306;
connStrBuilder.Database = "test";
connStrBuilder.Pooling = false;
connStrBuilder.ClientInteractive = true;
MySqlConnection myConn = new MySqlConnection(connStrBuilder.ToString());
MySqlCommand command = new MySqlCommand("select 1", myConn);
myConn.Open();
//If interactive_timeout is set to a value less than 60, the command will throw exception:
//Lost connection to MySQL server during query
Thread.Sleep(new TimeSpan(0, 0, 60));
try {
command.ExecuteNonQuery();
}
catch (MySqlException e) {
if (e.Code == 2013)
Console.WriteLine(e.Message);
}
}
Sub Main()
Dim connStrBuilder As MySqlConnectionStringBuilder = New MySqlConnectionStringBuilder()
connStrBuilder.UserId = "root"
connStrBuilder.Password = ""
connStrBuilder.Host = "localhost"
connStrBuilder.Port = 3306
connStrBuilder.Database = "test"
connStrBuilder.Pooling = False
connStrBuilder.ClientInteractive = True
Dim myConn As MySqlConnection = New MySqlConnection(connStrBuilder.ToString())
Dim command As MySqlCommand = New MySqlCommand("select 1", myConn)
myConn.Open()
'If interactive_timeout is set to a value less than 60, the command will throw exception:
'Lost connection to MySQL server during query
Thread.Sleep(New TimeSpan(0, 0, 60))
Try
command.ExecuteNonQuery()
Catch ex As MySqlException
If (ex.Code = 2013) Then
Console.WriteLine(ex.Message)
End If
End Try
End Sub