Transparent Statement Caching in Modern JDBC Drivers

Most Java developers have written code like this thousands of times, or at least their preferred ORM frameworks have: