JDBC GS executeUpdate method summary

Summary of executeUpdate() methods contained in a JDBC statement object.

  • JDBC API provides you the possibility to use the Data Manipulation Language (DML), which is as a part of the standard SQL, as arguments to methods, which then can perform SQL UPDATE, INSERT or DELETE statements on table rows in a database.
  • With the same methods, the JDBC API allows you to write your own SQL statements, using the Data Definition Language (DDL) which is as a part of the standard SQL, as arguments to methods, which would be to SQL CREATE, ALTER or DROP database objects.
    Statement interface has several methods for these purposes:
    Methods in Statement interface Description
    int executeUpdate(String sql) Executes the given SQL statement, and returns the update count.
    int executeUpdate(String sql, int autoGeneratedKeys) Same as executeUpdate(String sql) but for a SQL INSERT you can signals the driver a given flag about whether the auto-generated keys produced by this Statement object should be made available for retrieval.
    int executeUpdate(String sql, int[] columnIndexes) Same as executeUpdate(String sql) but for a SQL INSERT you can signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. The array contains the indexes (starting with 1 for the first) of the columns.
    int executeUpdate(String sql, String[] columnNames) Same as executeUpdate(String sql) but for a SQL INSERT you can signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval. The array contains the names of the columns.
  • The three last methods above can result in a possibility to retrieve the auto generated key for a INSERT SQL.
    To retrieve any auto generated key after an SQL execute() method use:
    Method in Statement interface Description
    ResultSet getGeneratedKeys() Retrieves any auto-generated keys created as a result of executing this Statement object. If this Statement object did not generate any keys, an empty ResultSet object is returned.

© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.