Springboot之JDBCTemplate

我爱海鲸 2024-08-14 10:24:28 暂无标签

简介jdbc、插入一个日期

使用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);

你好:我的2025

上一篇:Springboot之单元测试

下一篇:sftp相关