JDBC获取新增记录的自增主键
程序员文章站
2022-04-05 21:21:29
...
PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); stmt.setXXX(1, ...); ... stmt.executeUpdate(); ResultSet rs = stmt.getGeneratedKeys(); if (rs.next()) { rs.getLong(1); }