Swing0528笔记

1:table表单清空:

  DefaultTableModel dtm = (DefaultTableModel) this.bookType.getModel();
  dtm.setRowCount(0);

2:combox

  注意有时候默认选中的话最好前面加个判断.getItemCount()>0

2:多表查询

 1 public ResultSet bookList(Connection con,Book book) throws Exception{
 2         StringBuffer sb = new StringBuffer("select * from t_book b ,t_booktype t where b.bookTypeId = t.id");
 3         if(StringUtil.isNotNull(book.getBookName())){
 4             sb.append(" and b.bookName like '%" + book.getBookName()+ "%'");
 5         }
 6         if(StringUtil.isNotNull(book.getAuthor())){
 7             sb.append(" and b.author like '%" + book.getAuthor()+ "%'");
 8         }
 9         if(book.getPrice()!=-1){
10             sb.append(" and b.price = "+ book.getPrice());
11         }
12         if(StringUtil.isNotNull(book.getSex())){
13             sb.append(" and b.sex ='" + book.getSex()+"'");
14         }
15         if(book.getBookTypeId()!=-1){
16             sb.append(" and b.bookTypeId =" + book.getBookTypeId() );
17         }
18         
19         PreparedStatement pstmt=con.prepareStatement(sb.toString());
20         return pstmt.executeQuery();

 

posted on 2013-05-29 00:08  鱼东鱼  阅读(156)  评论(0编辑  收藏  举报

导航