KeyHolder keyHolder = new GeneratedKeyHolder();
int rowsAffected = jdbcTemplate.update( new PreparedStatementCreator() { 
     public PreparedStatement createPreparedStatement(Connection conn) throws SQLException { 
        PreparedStatement ps = conn.prepareStatement(insert_userpayment, new String[] {"id"});
        //ps.setString 
          return ps; 
                } 
     },keyHolder); 
    payment.setId(keyHolder.getKey().longValue()); // 保存插入的这条记录的主键id
 
 
而mysql中则不需要添加new String[] {"id"}