It depends on the JDBC engine. For instance, the JDBC engine for MySQL often doesn't actually create a server-side prepared statement (see MySQL docs and this SO question). In those cases, the PreparedStatement
interface only provides a separation between the query and parameters, for clarity and protection from injection attacks; every time you execute the PreparedStatement
, it will send over a fully-formed SQL query, which the MySQL server will then parse, optimize and execute. On the other hand, some systems (including MySQL with the right options -- see that second link) will use a "real" prepared statement, which means it'll only get parsed and optimized once.
But really, this is like asking for the memory characteristics of java.util.List
-- it's entirely up to the implementation, and thus can't be meaningfully answered for the interface in general.