View RSS Feed

JDBC

Supplying Values for PreparedStatement Parameters

Rate this Entry
by , 04-27-2012 at 08:08 PM (1601 Views)
You must supply values in place of the question mark placeholders (if there are any) before you can execute a PreparedStatement object. Do this by calling one of the setter methods defined in the PreparedStatement class. The following statements supply the two question mark placeholders in the PreparedStatement named updateSales:

Java Code:
updateSales.setInt(1, e.getValue().intValue());
updateSales.setString(2, e.getKey());
The first argument for each of these setter methods specifies the question mark placeholder. In this example, setInt specifies the first placeholder and setString specifies the second placeholder.

Submit "Supplying Values for PreparedStatement Parameters" to Facebook Submit "Supplying Values for PreparedStatement Parameters" to Digg Submit "Supplying Values for PreparedStatement Parameters" to del.icio.us Submit "Supplying Values for PreparedStatement Parameters" to StumbleUpon Submit "Supplying Values for PreparedStatement Parameters" to Google

Comments