从我的代码复制:
pInsertOid = connection.prepareStatement(INSERT_OID_SQL, Statement.RETURN_GENERATED_KEYS);
其中pInsertOid是准备好的语句。
然后您可以获取密钥:
// fill in the prepared statement andpInsertOid.executeUpdate();ResultSet rs = pInsertOid.getGeneratedKeys();if (rs.next()) { int newId = rs.getInt(1); oid.setId(newId);}希望这为您提供一个良好的起点。



