Oct 01

You can tell the driver to return the value of the auto incremented value and then use the getGeneratedKeys() method of the JDBC Statement class to access it.

// Tell the driver to return the value
statement.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);

// You can now access the auto incremented values
ResultSet rs = statement.getGeneratedKeys();
if (rs.next())
        autoKey = rs.getInt(1);

written by objects \\ tags:

Leave a Reply

You must be logged in to post a comment.