Question: I want to get the value of the last ID insert in a table. How I can do this?

Answer: 
```
SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1

```

See [docs](http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0004231.html).
```
int keyId = -1;
preparedStatement.executeUpdate();
resultSet = preparedStatement.getGeneratedKeys();
if (resultSet.next()) {
    keyId = rs.getInt(1);
}

```

<https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#getGeneratedKeys()>

Update: and don't forget to create preparedStatement with the following flag `Statement.RETURN_GENERATED_KEYS` otherwise it won't work)))