获取单值
int count = jdbcTemplate.queryForObject("select count(*) from tb1",Integer.class);
执行插入操作获取自增长ID
public Emp create(final Emp emp){final String sql = "insert into Emp (age,name)values(?,?)";KeyHolder keyHolder = new GeneratedKeyHolder();jdbc.update(new PreparedStatementCreator() {@Overridepublic PreparedStatement createPreparedStatement(Connection connection) throws SQLException {PreparedStatement ps = connection.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);ps.setInt(1, emp.getAge());ps.setString(2, emp.getName());return ps;}},keyHolder);int newEmpId= keyHolder.getKeys().get("id");emp.setId(newEmpId);return emp;}