< prev index next >

src/java.sql/share/classes/java/sql/PreparedStatement.java

Print this page




  39  * <P><B>Note:</B> The setter methods (<code>setShort</code>, <code>setString</code>,
  40  * and so on) for setting IN parameter values
  41  * must specify types that are compatible with the defined SQL type of
  42  * the input parameter. For instance, if the IN parameter has SQL type
  43  * <code>INTEGER</code>, then the method <code>setInt</code> should be used.
  44  *
  45  * <p>If arbitrary parameter type conversions are required, the method
  46  * <code>setObject</code> should be used with a target SQL type.
  47  * <P>
  48  * In the following example of setting a parameter, <code>con</code> represents
  49  * an active connection:
  50  * <PRE>
  51  *   PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
  52  *                                     SET SALARY = ? WHERE ID = ?");
  53  *   pstmt.setBigDecimal(1, 153833.00)
  54  *   pstmt.setInt(2, 110592)
  55  * </PRE>
  56  *
  57  * @see Connection#prepareStatement
  58  * @see ResultSet

  59  */
  60 
  61 public interface PreparedStatement extends Statement {
  62 
  63     /**
  64      * Executes the SQL query in this <code>PreparedStatement</code> object
  65      * and returns the <code>ResultSet</code> object generated by the query.
  66      *
  67      * @return a <code>ResultSet</code> object that contains the data produced by the
  68      *         query; never <code>null</code>
  69      * @exception SQLException if a database access error occurs;
  70      * this method is called on a closed  <code>PreparedStatement</code> or the SQL
  71      *            statement does not return a <code>ResultSet</code> object
  72      * @throws SQLTimeoutException when the driver has determined that the
  73      * timeout value that was specified by the {@code setQueryTimeout}
  74      * method has been exceeded and has at least attempted to cancel
  75      * the currently running {@code Statement}
  76      */
  77     ResultSet executeQuery() throws SQLException;
  78 




  39  * <P><B>Note:</B> The setter methods (<code>setShort</code>, <code>setString</code>,
  40  * and so on) for setting IN parameter values
  41  * must specify types that are compatible with the defined SQL type of
  42  * the input parameter. For instance, if the IN parameter has SQL type
  43  * <code>INTEGER</code>, then the method <code>setInt</code> should be used.
  44  *
  45  * <p>If arbitrary parameter type conversions are required, the method
  46  * <code>setObject</code> should be used with a target SQL type.
  47  * <P>
  48  * In the following example of setting a parameter, <code>con</code> represents
  49  * an active connection:
  50  * <PRE>
  51  *   PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
  52  *                                     SET SALARY = ? WHERE ID = ?");
  53  *   pstmt.setBigDecimal(1, 153833.00)
  54  *   pstmt.setInt(2, 110592)
  55  * </PRE>
  56  *
  57  * @see Connection#prepareStatement
  58  * @see ResultSet
  59  * @since 1.1
  60  */
  61 
  62 public interface PreparedStatement extends Statement {
  63 
  64     /**
  65      * Executes the SQL query in this <code>PreparedStatement</code> object
  66      * and returns the <code>ResultSet</code> object generated by the query.
  67      *
  68      * @return a <code>ResultSet</code> object that contains the data produced by the
  69      *         query; never <code>null</code>
  70      * @exception SQLException if a database access error occurs;
  71      * this method is called on a closed  <code>PreparedStatement</code> or the SQL
  72      *            statement does not return a <code>ResultSet</code> object
  73      * @throws SQLTimeoutException when the driver has determined that the
  74      * timeout value that was specified by the {@code setQueryTimeout}
  75      * method has been exceeded and has at least attempted to cancel
  76      * the currently running {@code Statement}
  77      */
  78     ResultSet executeQuery() throws SQLException;
  79 


< prev index next >