zoukankan      html  css  js  c++  java
  • Spring3.0.5 获取表中自增的主键(mysql)

        public int addWsstxCotent(final WsstxContent wsstxContent) {
            final String sql = "insert into wsstx_content(sstx_type,sstx_content,sstx_title,opr_time,ts_tag) values(?,?,?,now(),?)";
    //        this.jdbcTemplate.update(sql,
    //                new Object[]{wsstxContent.getSstxType(), wsstxContent.getSstxContent(),wsstxContent.getSstxTitle(), wsstxContent.getTsTag()});
            KeyHolder keyHolder = new GeneratedKeyHolder();  
            this.jdbcTemplate.update(
                    new PreparedStatementCreator() {
                        public PreparedStatement createPreparedStatement(Connection conn) throws SQLException {
                            PreparedStatement ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
                            ps.setInt(1, wsstxContent.getSstxType());
                            ps.setString(2, wsstxContent.getSstxContent());
                            ps.setString(3, wsstxContent.getSstxTitle());
                            ps.setString(4, wsstxContent.getTsTag());
                            return ps;
                        } 
                    } ,  keyHolder);
            int generatedId = keyHolder.getKey().intValue();
            return generatedId;
        }
  • 相关阅读:
    window.fonts
    smpt authentification 配置
    如何从思维上应对
    中文字体 英文字体
    Path Breadcrumbs
    drupal commerce app
    做视频或者什么模块开发之类的
    分页符 箭头 难看
    theme wrapper 例子
    background position 稍微深入
  • 原文地址:https://www.cnblogs.com/yshyee/p/3676007.html
Copyright © 2011-2022 走看看