使用jdbcTemplate的时候 出现了一个问题,一直在报null
就是我在插入时间的时候,我一直以为是时间的插入问题,但是经过非常多次的调试,是userId为null,但是报的错确实时间,可以说非常蛋痛了。
String userId = // 获取userId
userId = userId == null ? "" : userId;
// 获取当前时间
Date now = new Date();
// 转换为 Timestamp
Timestamp timestamp = new Timestamp(now.getTime());
String sql = "INSERT INTO t_module (id, create_by, create_time) " +
"VALUES (?, ?, ?)";
jdbcTemplate.update(sql, id,userId, timestamp);