Given: different java threads are accessing a database (DB2) and
issuing almost the same SQL statements. Say, Thread 1: "select a from b where c=1,d=1,e=1;" and Thread 2: "select a from b where c=2;d=2;e=2;". The same for updating the table. Threads are using one static connection and different java.sql.Statement created for every SQL statement.

Question: Appears an idea to combine all such similar SQL statements into a PreparedStatement to execute it several times with different parameters. Any ideas? Should I develop an object that holds PrepearedStatemets, monitors all statements from all threads and updates preparedStatement's parameters for a call that suits? Are there other suggestions? What about thread safety?

Thanks to all.