The current JDBC driver supports the RETURNING clause and it does exactly what someone would want. ResultSet rs = statement.executeQuery("INSERT INTO z(myField) VALUES(0) RETURNING keyName") ; int key = rs.getInt(1); Hallelujah
pgsql-jdbc by date:
Соглашаюсь с условиями обработки персональных данных