Error added: 2013-06-25T19:12:06Z
KeyHolder holder = new GeneratedKeyHolder(); final String sql = "INSERT INTO sometable (something, somethingelse) VALUES (?,?)"; PreparedStatementCreator psc = new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); ps.setString(1, something); ps.setString(2, somethingElse); return ps; } }; getJdbcTemplate().update(psc, holder); return (Integer) holder.getKeyList().get(0).get("id");
If you know the answer, please add your own solution below.
If you don't know, but find out later, please come back and share your answer - there will be other people
struggling with this too.
If you want to be notified via email when this is solved, enter your email address here: