P粉2774647432023-08-28 08:17:05
Even if you could ensure that the "same" connection is used on subsequent requests, this won't help because part of allocating a connection from the pool involves resetting things related to session state.
This is by design and a good thing because otherwise you could leak private data from one database session to another unrelated session. For example, this would be a problem if one user stored some sensitive data in a temporary table and then another user's database session could read that temporary table. The same applies to outstanding transactions, session variables, and connection character sets. All of these are reset when a connection is allocated from the pool.
So if you use temporary tables, you should only use them during the same request because they will be deleted after the connection is used.
If you need to use the data from the previous request in the next request, you can: