• 得到新序列号


    import org.springframework.jdbc.core.PreparedStatementCreator;
    import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
    import org.springframework.jdbc.support.GeneratedKeyHolder;
    
    
    
    final String sql = "insert into riv_outbound_no_seq(seq_name) values('onh_notice_no')";
            KeyHolder keyHolder1 = new GeneratedKeyHolder();
            String onhNoticeNo = null;
            jdbcTemplate.getJdbcOperations().update(new PreparedStatementCreator() {
                public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
                    PreparedStatement ps = con.prepareStatement(sql, new String[] {"seq"});
                    return ps;
                }
            }, keyHolder1);
            if (null != keyHolder1.getKey()) {
                String currDate = CommonMethodHelper.convertDate2String("yyyyMMdd");
                String serialNo = String.format("%09d", keyHolder1.getKey()); 
                onhNoticeNo = "OBN" + currDate + serialNo;
                onh.setOnhNoticeNo(onhNoticeNo);
            }
    CREATE TABLE `riv_outbound_no_seq` (
      `seq` bigint(7) unsigned zerofill NOT NULL AUTO_INCREMENT,
      `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      `seq_name` varchar(40) NOT NULL,
      PRIMARY KEY (`seq`)
    ) ENGINE=InnoDB AUTO_INCREMENT=12176347 DEFAULT CHARSET=utf8;
  • 相关阅读:
    P、NP、NPC、NPH问题介绍
    过河卒 bfs搜索
    对迪杰斯特拉算法的理解
    第七周
    周作业
    月考一
    第四周
    第三周
    第二周作业
    46期第一次作业
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/6509489.html
Copyright © 2020-2023  润新知