I want to make use of spring JdbcTemplate
to insert a line and return the id autogenerated by the mysql
db.
Without spring I'd do similar as follows:
String sql = "INSERT INTO mytable (id, filename, timestamp) VALUES (NULL, ?, NOW())";
Statement st = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
st.setString("test.csv");
st.executeUpdate();
st.getGeneratedKeys().next().getLong(1);
Question: how could I achive the same with JdbcTemplate
?