I am looking for a way to intercept the connection that JDBCTemplate creates internally i.e. the connection that is created when the function getConnection() is called by JDBCTemplate.
ex: if I use jdbcTemplate.update(query); I want to get the information of the connection that was used to complete this update statement. Is there a way to see the metadata of the connection mid or post execution of this statement ? I am using C3P0 connection pool.
Many people have suggested using DataSourceUtils.getConnection() , but that just fetches a new connection from the pool and does not solve my issue.
This thread also effectively asks the same question: How to get current Connection object in Spring JDBC