今天考虑加入书架的个人化,首先对书架的后台数据格式进行了设计
//加入书架 public boolean addshelf(Bookshelf bookshelf){ String sql="insert into Bookshelf(BookName,username) values(?,?)"; Object obj[]= {bookshelf.getBookName(),bookshelf.getUsername()}; return DBUtil.executeUpdate(sql,obj); } //从书架删除 public boolean deleteshelf(Bookshelf bookshelf) { String sql="delete from Bookshelf where id=? and BookName=? and username=? "; Object obj[]= {bookshelf.getId(),bookshelf.getBookName(),bookshelf.getUsername()}; return DBUtil.executeUpdate(sql,obj); }
package entity; public class Bookshelf { private int id; private String BookName; private String username; public Bookshelf() { } public Bookshelf(String bookName, String username) { BookName = bookName; this.username = username; } public Bookshelf(int id, String bookName, String username) { this.id = id; BookName = bookName; this.username = username; } @Override public String toString() { return "Bookshelf [id=" + id + ", BookName=" + BookName + ", username=" + username + "]"; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getBookName() { return BookName; } public void setBookName(String bookName) { BookName = bookName; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } }
明天对Android端进行重构,并实现与web的交互