zoukankan      html  css  js  c++  java
  • mysql增删改查

    public class BookTypeDao {
      增加
    public int bookTypeAdd(Connection con, BookType bookType) throws SQLException{ String sql="insert into t_bookType values(null,?,?)"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, bookType.getBookTypeName()); pstmt.setString(2, bookType.getBookTypeDesc()); return pstmt.executeUpdate(); }
      查找
    public ResultSet bookTypeList(Connection con,BookType bookType) throws SQLException{ StringBuffer sb=new StringBuffer("select * from t_bookType") ; if(StringUtil.isNotEmpty(bookType.getBookTypeName())){ sb.append(" and bookTypeName like '%"+bookType.getBookTypeName()+"%'"); } PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where")); return pstmt.executeQuery(); }
      删除
    public int bookTypeDelete(Connection con,String id) throws SQLException{ String sql="delete from t_bookType where id=?"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, id); return pstmt.executeUpdate(); }
      修改
    public int bookTypeModify(Connection con,BookType bookType) throws SQLException{ String sql="update t_bookType set bookTypeName=?,bookTypeDesc=? where id=?"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, bookType.getBookTypeName()); pstmt.setString(2, bookType.getBookTypeDesc()); pstmt.setInt(3, bookType.getId()); return pstmt.executeUpdate(); } }
  • 相关阅读:
    js技巧收集(200多个)
    Ajax跨域访问的问题?
    最新软件下载提供列表
    美食家家V1.1[强力推荐]
    吉他和弦帮手以及曲子下载
    网译(在线中文英语翻译软件)[强力推荐]
    网上电子婚宴请柬
    吉他和弦帮手v2.3注册机
    1万多个英语单词mp3下载
    菜谱大全数据库下载(ACCESS)
  • 原文地址:https://www.cnblogs.com/xlwh/p/8592927.html
Copyright © 2011-2022 走看看