日期:2014-05-17  浏览次数:20758 次

求助,关于查询图书
public void Select(String value){
Connection conn=DataBaseUtil.getConnection();
String sql="select * from book where bname like bname='%"+value+"%' or bauthor='%"+value+"%'";
PreparedStatement ps=null;
ResultSet rs=null;
List<Book> book=new ArrayList<Book>();
try{
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();
while(rs.next()){

for(Book books:book){
System.out.println(books);
}
} }catch(Exception e){
e.printStackTrace();
}
}
我该如何把查询到的值添加到book中,

------解决方案--------------------
探讨
public void Select(String value){
Connection conn=DataBaseUtil.getConnection();
String sql="select * from book where bname like bname='%"+value+"%' or bauthor='%"+value+"%'";
PreparedStatement ps=n……