CRUD
read:
String sql = "select b.*,c.name as bookcaseName,p.pubname as publishing,t.typename from tb_bookinfo b left join tb_bookcase c on b.bookcase=c.id join tb_publishing p on b.ISBN=p.ISBN join tb_booktype t on b.typeid=t.id where b." + f + "='" + key + "'"; System.out.println("查询借阅信息时的SQL:" + sql); ResultSet rs = conn.executeQuery(sql); try { if (rs.next()) { bookForm = new BookForm(); bookForm.setBarcode(rs.getString(1)); }
insert:
sql = "Insert into tb_bookinfo (barcode,bookname,typeid,author,translator,isbn,price,page,bookcase,inTime,operator) values('" + bookForm.getBarcode() + "','" + bookForm.getBookName()+ "')"; falg = conn.executeUpdate(sql); System.out.println("添加图书的SQL:" + sql);
update:
String sql = "Update tb_bookinfo set typeid=" + bookForm.getTypeId() + ",author='" + bookForm.getAuthor() + "',translator='" + bookForm.getTranslator() + "',isbn='" + bookForm.getIsbn() + "',price=" + bookForm.getPrice() + ",page=" + bookForm.getPage() + ",bookcase=" + bookForm.getBookcaseid() + " where id=" + bookForm.getId() + ""; int falg = conn.executeUpdate(sql);
delete:
String sql = "UPDATE tb_bookinfo SET del=1 where id=" + bookForm.getId() + ""; int falg = conn.executeUpdate(sql); System.out.println("删除时的SQL:" + sql);