I have a REST web service written in Java/Spring boot and running on Tomcat 9.
I need to create a MySQL temporary table in one web service call and access it later in another service call. As temporary tables are connection scoped, I need to use the same connection used to create the table during the first call in the "select" query in the second call.
The problem is that Tomcat manages JDBC connections in a connection pool. In the second service call,whenever I create a JDBC connection, any connection from the pool can be picked up. In this case, the temporary table will not be visible.
My question is: how can I pick the same connection from the connection pool? Is there any kind of id/tag that distinguishes them?