Connection.prepareStatement
Interface Overview | Interface Members |
This Package |
All Packages
public abstract PreparedStatement prepareStatement( String sql ) throws SQLException
Parameters
- sql
- a SQL statement that may contain one or more '?' IN
parameter placeholders
Returns
a new PreparedStatement object containing the
pre-compiled statement
Description
A SQL statement with or without IN parameters can be
pre-compiled and stored in a PreparedStatement object. This
object can then be used to efficiently execute this statement
multiple times.
Note: This method is optimized for handling
parametric SQL statements that benefit from precompilation. If
the driver supports precompilation, prepareStatement will send
the statement to the database for precompilation. Some drivers
may not support precompilation. In this case, the statement may
not be sent to the database until the PreparedStatement is
executed. This has no direct affect on users; however, it does
affect which method throws certain SQLExceptions.
Exceptions
SQLException
if a database-access error occurs.