I have a manager threads which has its respective worker threads.The JDBC Connection is created one time by the parent of the manager thread and is passed to each of the worker threads to prepare their set of PreparedStatement objects.The service runs forever until one point of time in a day during which the main thread is interrupted and the connection object is closed and after that i call
System.exit(0);
So with this approach there is no track of how and when preparedstatements that are with the workers would be closed. Will calling close() on Connection object that is with the main thread release the db resources and gracefully close the PreparedStatements.If not, how can i make the threads to break out from their forever loop that they check on interruption flag and execute their finally block then notify the parent somehow and close the Connection object too.
EDIT: Each worker thread has 9 PreparedStatements and hence max 54 threads can be open at a time and at stake.
EDIT2- The duplicate marked question states that
With a pool in place you can open/close connections and prepared statements according to best-practice and leave the resource management to the pool.
I cannot close the PreparedStatements and leave the rest to the pool,as far as i think it will only clog my pool.