Auto-generated keys
- Last Updated: June 13, 2020
- 1 minute read
- DataDirect Connectors
- JDBC
- Oracle Eloqua 6.0
- Documentation
The driver supports retrieving the values of auto-generated keys. An auto-generated key returned by the driver is the value of an auto-increment column.
An application can return values of auto-generated keys when it executes an
Insert statement. How you return these values depends on whether you are using an Insert
statement with a Statement object or with a
PreparedStatement object, as outlined in the following scenarios:
- When using an Insert statement with a
Statementobject, the driver supports the following form of theStatement.executeandStatement.executeUpdatemethods to instruct the driver to return values of auto-generated keys:Statement.execute(String sql, int autoGeneratedKeys)Statement.execute(String sql, int[] columnIndexes)Statement.execute(String sql, String[] columnNames)Statement.executeUpdate(String sql, int autoGeneratedKeys)Statement.executeUpdate(String sql, int[] columnIndexes)Statement.executeUpdate(String sql, String[] columnNames)
- When using an Insert statement with a
PreparedStatementobject, the driver supports the following form of theConnection.prepareStatementmethod to instruct the driver to return values of auto-generated keys:Connection.prepareStatement(String sql, int autoGeneratedKeys)Connection.prepareStatement(Stringsql, int[] columnIndexes)Connection.prepareStatement(Stringsql, String[] columnNames)
An application can retrieve values of auto-generated keys using the
Statement.getGeneratedKeys() method. This method returns a
ResultSet object with a column for each auto-generated key.
See also
Refer to Designing JDBC applications for performance optimization in the Progress DataDirect for JDBC Drivers Reference for more information about using prepared statement pooling to optimize performance.