wellnwill

PreparedStatement Interface

  • An object that represents precompiled SQL statement
  • This object can then be used to efficiently execute this statement multiple times
  • The setter methods (setShort, setString, and so on) for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter.
  • For instance, if the IN parameter has SQL type INTEGER, then the method setInt should be used

Commonly used methods of PreparedStatement interface

// Executes the SQL statement in this PreparedStatement object,
// which may be any kind of SQL statement.
boolean  execute()

/**
 * Executes the SQL statement in this PreparedStatement object, 
 * which must be an SQL Data Manipulation Language (DML) statement,
 * such as INSERT, UPDATE or DELETE; or 
 * an SQL statement that returns nothing, such as a DDL statement.
 */
default  long executeLargeUpdate()

/**
 * Executes the SQL query in this PreparedStatement object and 
 * returns the ResultSet object generated by the query.
 */
ResultSet  executeQuery()

/**
 * Executes the SQL statement in this PreparedStatement object, 
 * which must be an SQL Data Manipulation Language (DML) statement, 
 * such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, 
 * such as a DDL statement.
 */
int  executeUpdate()

// Sets the designated parameter to the given Java int value. 
void  setInt(int parameterIndex, int x)

// Sets the designated parameter to the given Java String value.
void  setString(int parameterIndex, String x)

Insert using PreparedStatement

 
Footer with Map

Top