Executes the given SQL statement and signals the driver that the
auto-generated keys indicated in the given array should be made available
for retrieval. This array contains the names of the columns in the
target table that contain the auto-generated keys that should be made
available. The driver will ignore the array if the SQL statement
is not an
INSERT
statement, or an SQL statement able to return
auto-generated keys (the list of such statements is vendor-specific).
Returns:
either the row count for
INSERT
,
UPDATE
,
or
DELETE
statements, or 0 for SQL statements
that return nothing
Parameters:
-
sql - 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.
-
columnNames - an array of the names of the columns that should be
returned from the inserted row
Throws:
-
SQLException - if a database access error occurs,
this method is called on a closed
Statement
, the SQL
statement returns a
ResultSet
object, or the
second argument supplied to this method is not a
String
array
whose elements are valid column names
-
SQLFeatureNotSupportedException - if the JDBC driver does not support this method
Since:
1.4