Simple answer: It doesn't. The MySQL driver - by default - will simply execute a query string created from the parameterized query and the (escaped) parameter values. It will create this query locally by replacing the parameter placeholders with the escaped values and then send it to the server
Note that JDBC does not require that a PreparedStatement
is actually prepared server side, nor that it 'improves' performance. JDBC only requires that they work; as in: you can specify queries with ?
as parameterplaceholders, and the driver will correctly execute the statement with the values set through the setXXX
methods.
Also note that MySQL does have server side prepared statements, but you need to explicitly enable this using the connection property useServerPrepStmts
with value true
.