Hi, there are a couple of use-cases.
1) To maintain some metadata/state per connection (which will be discarded on connection close by supplying a closeHandler).
2) To keep track of how many new connections are created v/s re-used on the client
The primary reason why this came up is the following:
I'm trying to set some session/connection parameters with a mysql backend, which would have traditionally been done by supplying "sessionVariables" query parameter
as part of jdbcUrlParams. Since I'm not able to do this with the MySqlClient, the alternative is to use withConnection, and then send a "SET" before performing every query on that connection.
In order to avoid doing this, one approach is that I maintain some state per connection in the application, and only send the "SET" command if the connection is a newly established one.
I realized later that I can also use the state to keep track of new v/s re-used connections etc.