28.11 PreparedStatements
A PreparedStatement
enables you to create compiled SQL statements that execute more efficiently than Statement
s. PreparedStatement
s can also specify parameters, making them more flexible than Statement
s—you can execute the same query repeatedly with different parameter values. For example, in the books
database, you might want to locate all book titles for an author with a specific last and first name, and you might want to execute that query for several authors. With a PreparedStatement
, that query is defined as follows:
The two question marks (?
) in the the preceding SQL statement’s last line are placeholders for ...
Get Java How to Program (early objects), 9/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.