title: Why does MySQL create 4 connections for the same user?
body: <p>I have Web API 2 application written in VB.NET. The <code>API</code> connects to a <code>MySQL</code> database. The user can do a lot of operations, fetching different kinds of data there are a lot of different GET/POST methods inside the controller.</p>
  
  <p>I was wondering just why when the user does their first operation with the REST service, MySQL creates 4 connections for the same user? </p>
  
  <p>All the methods to fetch or insert data are written with <code>Using</code> method so I'm sure that all connections are disposed properly.</p>
  
  <p>Each user will be logged in and will do operations on its own database. But here is how the User connections list looks like when I'm logged with one user only:</p>
  
  <p><a href="https://i.stack.imgur.com/GoL5L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GoL5L.png" alt="enter image description here"></a></p>
  
  <p>Here is how one of <code>GET</code> methods is written:</p>
  
  <pre><code>    &lt;HttpGet()&gt;
      &lt;Route("confirm")&gt;
      Public Function ConfirmPrenotazioni(ByVal id As String)
          Try
              'Here i'm fetching the DB name from jwt token to connect the user
              Dim token As String = Request.Headers.GetValues("jwt_token").First()
              Dim principals = TokenManager.Principals(TokenManager.GetPrincipal(token))
              If principals Is Nothing Then Return New HttpResponseMessage(HttpStatusCode.Unauthorized)
              Dim reservation As Reservation = New Reservation
  
              Return reservation.ConfirmPrenotazione(id, principals.piva)
          Catch ex As Exception
              Return New HttpResponseMessage(HttpStatusCode.Unauthorized)
          End Try
  
      End Function
  </code></pre>
  
  <p>And here is how the ConfirmPrenotazione is written:</p>
  
  <pre><code>  Public Function ConfirmPrenotazione(ByVal id As String, ByVal piva As String) As String
          Dim SQLConnect As String = "Server=127.0.0.1;Port=3306;Database=" &amp; piva &amp; ";Uid=root;Pwd=tax;"
          Using cn As New MySqlConnection(SQLConnect)
              cn.Open()
              Using cmd As New MySqlCommand("UPDATE prenota_tavoli SET STATO_PTV = 'ARR', ORAARRIVO_PTV = @Oraarrivo WHERE ID_PTV = @Id AND STATO_PTV NOT LIKE('%ARR%')", cn)
                  cmd.Parameters.AddWithValue("@Id", id)
                  cmd.Parameters.AddWithValue("@Oraarrivo", Format(Date.Now.AddMinutes(15), "yyyy-MM-dd HH\:mm") &amp; ":00")
                  cmd.ExecuteNonQuery()
  
                  Return "OK"
              End Using
          End Using
  
          Return "ERR"
      End Function
  </code></pre>