当前位置:网站首页>JdbcTemplate插入并返回主键
JdbcTemplate插入并返回主键
2022-06-12 21:25:00 【围城_危城】
public static int getMemberId(JdbcTemplate jdbcTemplate, int orgId) {
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(con -> {
String sql="INSERT INTO t_g_primarykey(ord_id,create_time,day_time) VALUES(?,?,?)";
PreparedStatement ps = con.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
ps.setInt(1, orgId);
ps.setLong(2, ComDateUtils.getUnixCurrTime());
ps.setLong(3,DateUtil.getTodayZeroTimeTemp());
return ps;
}, keyHolder);
return Optional.ofNullable(keyHolder.getKey()).orElse(0).intValue();
}
边栏推荐
- Ubuntu 16.04 installing mysql5.6
- Understanding of functions
- makefile 的ifeq,filter,strip 简单使用
- remote: Support for password authentication was removed on August 13, 2021
- GNS安装与配置
- remote: Support for password authentication was removed on August 13, 2021
- torch. Finfo function
- Pointer and array & pointer and const & struct and Const
- 一款高颜值的MySQL管理工具
- 二分查找
猜你喜欢

Teamwork collaboration application experience sharing | community essay solicitation

Design and practice of Hudi bucket index in byte skipping

Data visualization - Calendar chart

Integrated monitoring solution for power environment of small and medium-sized computer rooms

GNS installation and configuration

leetcode:207. Class Schedule Card

My way of programming

What are the disadvantages of bone conduction earphones? Analysis of advantages and disadvantages of bone conduction earphones

Smart management of green agriculture: a visual platform for agricultural product scheduling

Summary of machine learning materials
随机推荐
lintcode:127 · 拓扑排序
Main stages of garbage collection in ZGC
What's a good gift for the goddess Festival? Gift recommendation for the goddess Festival on March 8
Pointer and array & pointer and const & struct and Const
Sorting out the knowledge points of primary and secondary indicators
Introduction to the characteristics of balancer decentralized exchange market capitalization robot
Bubble sort
Solution of multi machine room dynamic loop status network touch screen monitoring
Image processing 12- image linear blending
Recursively call knowledge points - including example solving binary search, frog jumping steps, reverse order output, factorial, Fibonacci, Hanoi tower.
A high-value MySQL management tool
多机房动环状态网络触摸屏监控解决方案
Structure knowledge points all in
测试基础之:单元测试
Rearrangement exercises
To understand Devops, you must read these ten books!
Inrelease: the following signature cannot be verified because there is no public key: no_ PUBKEY EB3E94ADBE1229CF
Design and practice of Hudi bucket index in byte skipping
String Basics
Preliminary understanding of regular expressions (regex)