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);
轉載于:https://www.cnblogs.com/kakaisgood/p/5620289.html