This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
PreparedStatement is more efficient than Statement object if you are executing similar statements multiple times. When a PreparedStatement is created, the SQL statement is sent to the database for precompilation. The precompiled form of a prepared statement is cached only as long as the PreparedStatement instance is alive, so the performance benefits are only obtained when reusing the same PreparedStatement instance, setting different parameters on each invocation.
Oracle for instance will cache parsed SQL and execution plans in its own shared memory area. They will stay there even if the session that first submitted it drops the connection, unless and until they are aged out by more recently requested statements needing the space. [ December 12, 2006: Message edited by: Chris Hendy ]