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(); } }
  • 相关阅读:
    0-1性能测试需求分析
    1-10jmeter关联,正则表达式(待巩固)
    1-9jmeter集合点,并发操作
    1-8.jmeter设置断言(检查点)
    1-6jmeter性能测试基础
    泛型中的协变和逆变
    jsPlumb
    jQuery UI vs Kendo UI & jQuery Mobile vs Kendo UI Mobile
    31天重构
    Visual Studio 小工具
  • 原文地址:https://www.cnblogs.com/xlwh/p/8592927.html
Copyright © 2011-2022 走看看