Section 24.8 PreparedStatements
• PreparedStatement
s (p. 1082) are compiled, so they execute more efficiently than Statement
s.
• PreparedStatement
s can have parameters, so the same query can execute with different arguments.
• A parameter is specified with a question mark (?
) in the SQL statement. Before executing a PreparedStatement
, you must use PreparedStatement
’s set methods to specify the arguments.
• PreparedStatement
method setString
’s (p. 1082) first argument represents the parameter number being set and the second argument is that parameter’s value.
• Parameter numbers are counted from 1, starting with the first question mark (?
).
• Method setString
automatically escapes String
parameter values as necessary.
• Interface PreparedStatement ...
Get Java™ How To Program (Early Objects), Tenth Edition 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.