Java – Preparedstatement cache – what does it mean (how does it work)
I'm using, for example, c3p0 and some defined "maxstatements" for preparestatement caching
Now I send a prepared declaration that it has no cache Now I send it and it is cached What's the difference between what happens in the first case and what happens in the second case What is the content sent to the DB server in the first case and the second case?
thank you.
Solution
There is no cache. Each time a Preparedstatement is requested from the connection, a new Preparedstatement will be obtained Through caching, if you provide the same SQL string, you will often get exactly the same Java object of type Preparedstatement If you provide the same SQL to the Preparedstatement, even if you use different parameters, the database can usually reuse information like the execution plan, but only when you continue to use the same Preparedstatement Caching is easier by not requiring your application to keep the Preparedstatement reference itself