http://dev.mysql.com/doc/refman/5.6/en/connector-j-usagenotes-statements-callable.html#connector-j-examples-callablestatement has the example you are referring to, and it says:
CallableStatement also supports setting parameters by name:
So this is specific to CallableStatement
which is used for invoking stored procedures, and it's specific to MySQL's JDBC implementation. This is not standard for the JDBC spec.
This extension has been implemented only for CallableStatement
, not for PreparedStatement
.
Re your comment:
Yes, that's correct, MySQL does not support named parameters, only positional parameters.
Client interfaces like Connector/J CallableStatement and PHP's PDO library actually have to do some extra work to mimic named parameters.