mysql 插入Timestamp数据怎样直接插入时间戳数值

2024-12-14 20:10:20
推荐回答(1个)
回答1:

请参考
public static void insertDemo(String[] args) throws Exception {
MsgSwapDAOImpl dao = new MsgSwapDAOImpl();
Connection conn = dao.jdbcUtil.getConnection();
String appKey ="40825Td288461463";
String msg = "wlllllll";
conn.setAutoCommit(false);
String sql = "insert into TTT(ID, CREATE_DATE) values(?,?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, 888888);
pstmt.setTimestamp(2, TimeUtil.nowTimestamp());