日期:2014-05-16 浏览次数:20562 次
KeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update(new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement( "INSERT INTO Test (id, NAME) VALUES (phoenix_sequence.nextval,?)", new String[] { "ID" }); ps.setString(1, "heipark"); return ps; } }, keyHolder); Long generatedId = keyHolder.getKey().longValue(); System.out.println(generatedId);
select phoenix_sequence.nextval from dual