当前位置:网站首页>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();
}
边栏推荐
- Scope and scope chain
- Shell language
- 插入排序
- InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY EB3E94ADBE1229CF
- Can tonghuashun open an account? Can tonghuashun directly open the security of securities companies on the app? How to open an account online when buying stocks
- leetcode:207. 课程表
- Smart management of green agriculture: a visual platform for agricultural product scheduling
- 多机房动环状态网络触摸屏监控解决方案
- Summary of machine learning materials
- #981 Time Based Key-Value Store
猜你喜欢

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

A high-value MySQL management tool

RestTemplate的@LoadBalance注解

Scope and scope chain

Introduction to the characteristics of balancer decentralized exchange market capitalization robot

风控建模十:传统建模方法存在的问题探讨及改进方法探索

Algorinote_ 2_ Main theorem and Akra bazzi theorem

leetcode:207. Class Schedule Card
![Fill in the checklist & lt; int> Have default values? [repeat] - fill list & lt; int> with default values? [duplicate]](/img/65/a214d137e230b1a1190feb03660f2c.jpg)
Fill in the checklist & lt; int> Have default values? [repeat] - fill list & lt; int> with default values? [duplicate]

#141 Linked List Cycle
随机推荐
Risk control modeling X: Discussion on problems existing in traditional modeling methods and Exploration on improvement methods
选择排序
InRelease: 由于没有公钥,无法验证下列签名: NO_PUBKEY EB3E94ADBE1229CF
USB mechanical keyboard changed to Bluetooth Keyboard
Teamwork collaboration application experience sharing | community essay solicitation
What did new do
Yanghui triangle code implementation
指针与数组&指针与const&结构体与const
Redis cluster mget optimization
风控建模十:传统建模方法存在的问题探讨及改进方法探索
ASCII 码对照表
leetcode:207. Class Schedule Card
Leetcode: 210. Programme II
Research Report on market supply and demand and strategy of China's hydraulic injection molding machine industry
Research Report on market supply and demand and strategy of China's hydraulic hammer industry
Scope and scope chain
Bluetooth for Delphi xe7
冒泡排序
Algorinote_ 2_ Main theorem and Akra bazzi theorem
The salted fish has been transmitted for 5W times, and the latest spring recruit face-to-face test questions of bytes have been leaked