Few questions on JDBC coding:
- For a single client application, do we need a Connection pool?
- Is it a good idea to create a Connection at beginning and keep it alive without close it until application exit? Why?
- PreparedStatement is associated with Connection, if my connection is not closed after each query, why not keep the PreparedStatement alive and reuse it in other methods?
- if we create PreparedStatement each query, does database knows it is the same PreparedStaement and ignore unnecessary actions after the first time?
- PreparedStatement is not create once and reuse many times statement? if yes, why need close it each time?
I know the call to close() will release resource. But If we know we are going to use it later, why release it and then request it again later?
How about multi-client application? we need connection pool and so we need to create and close Connection, Statement and PreparedStatement each time?
thanks,