The current JDBC driver supports the RETURNING clause and it doesexactly what someone would want.
ResultSet rs = statement.executeQuery("INSERT INTO z(myField) VALUES(0)RETURNING keyName") ;int key = rs.getInt(1);
Hallelujah