Question : sleeping connections in mysql

I see a lot of sleepling connection_threads in mysql. eventually they will close, but sometimes that will take a long time.

this is the code I use:

Imports System.Data
Imports MySql.Data.MySqlClient

Dim connString As String = "server=localhost; user id=xxx; password=xxx; database=xxx; pooling=false;"
Dim con = New MySqlConnection(connString)
con.Open()
Dim query As String = "query string here"
Dim ds = New DataSet()
Dim da = New MySqlDataAdapter(query, con)
da.Fill(ds)
//code here//
ds.Dispose()
da.Dispose()
con.Close()
con.Dispose()

is there a way to get rid of those sleeping commands?

Answer : sleeping connections in mysql

You can directly kill those sleeping threads using below commands(from SQL prompt or from gui client)..where id is the id of the connection/sleeping thread...when you see a show processlist.

kill id;

Alternatively, you may want to you set a lower value(in seconds) for these should be done by setting in my.cnf(for windows my.ini)..alternatively these can be set at session level also..

wait_timeout = 120
interactive_timeout = 90

wait_timeout: The number of seconds the server waits for activity on a noninteractive connection before closing it. This timeout applies only to TCP/IP and Unix socket file connections, not to connections made via named pipes, or shared memory

interactive_timeout: The number of seconds the server waits for activity on an interactive connection before closing it.
Random Solutions  
 
programming4us programming4us