java sql插入_java 中如何使用sql插入语句?
ublic int save(Notices notice) throws SQLException{
String sql = "insert into noticeinfo(notice_title,notice_type,notice_content,notice_add_time,user_id,user_table_id,class_table_id,notice_state,is_important)"+"values(?,?,?,?,?,?,?,?,?)";
PreparedStatement pstmt = super.getConnection().prepareStatement(sql);
pstmt.setString(1, notice.getNotice_title());
pstmt.setInt(2, notice.getNotice_type());
pstmt.setString(3, notice.getNotice_content());
pstmt.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
pstmt.setString(5, notice.getUser_id());
pstmt.setInt(6, notice.getUser_table_id());
pstmt.setInt(7, notice.getClass_table_id());
pstmt.setInt(8, notice.getNotice_state());
pstmt.setInt(9, notice.getIs_important());
int i = pstmt.executeUpdate();
return i;
}
總結
以上是生活随笔為你收集整理的java sql插入_java 中如何使用sql插入语句?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 高效KMP字符匹配算法就这么简单
- 下一篇: 第一次收到这么用心的感谢信