当前位置:网站首页>Jdbctemplate inserts and returns the primary key
Jdbctemplate inserts and returns the primary key
2022-06-12 21:26:00 【Besieged city_ city with high walls】
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();
}
边栏推荐
- 递归调用知识点-包含例题求解二分查找、青蛙跳台阶、逆序输出、阶乘、斐波那契、汉诺塔。
- New product release Junda intelligent integrated environmental monitoring terminal
- The salted fish has been transmitted for 5W times, and the latest spring recruit face-to-face test questions of bytes have been leaked
- 字符串基础知识
- Bubble sort
- Data visualization - biaxial comparison effect
- NIO使用指南
- Sorting out the knowledge points of primary and secondary indicators
- 模块八:设计消息队列存储消息数据的MySQL表
- Image processing 12- image linear blending
猜你喜欢

Test basis: unit test

Image processing 12- image linear blending

Lake shore PT-100 platinum resistance temperature sensor

RestTemplate的@LoadBalance注解

Data visualization diagram microblog forwarding diagram

leetcode:210. 課程錶 II

Lintcode:127. Topology sorting

leetcode:210. Schedule II

Design and practice of Hudi bucket index in byte skipping

leetcode:207. 课程表
随机推荐
GNS installation and configuration
Product Manager: "click here to jump to any page I want to jump" -- decoupling efficiency improving artifact "unified hop routing"
Redis cluster mget optimization
remote: Support for password authentication was removed on August 13, 2021
leetcode:207. 课程表
zgc的垃圾收集的主要阶段
Select sort
【目标检测】|Dive Deeper Into Box for Object Detection 基于FCOS新训练方法
Module 8: Design message queue MySQL table for storing message data
Data visualization - biaxial comparison effect
#141 Linked List Cycle
Access control system based on RFID
Is it safe to open an account in flush? How to open an account online to buy stocks
Ubuntu16.04 completely delete MySQL database
USB mechanical keyboard changed to Bluetooth Keyboard
二分查找
EU officially released the data act, Ukraine was attacked by DDoS again, kitchen appliance giant Meiya was attacked, internal data leakage network security weekly
nn. PReLU(planes)
The Post-00 financial woman with a monthly salary of 2W conquered the boss with this set of report template
Binary search