我用servlet往bean传入一个sql语句,如何再serlvet中判断结果集是否为空。
这是servlet代码
////////////////////////////////////////////////////////////////
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
HttpSession session = request.getSession(true);
PrintWriter out = response.getWriter();
String search = request.getParameter("search"

;
String sql = "select title from titles where title_id in(select title_id from titleauthor where au_id in(select au_id from authors where au_lname="+"'"+search+"'"+"

)";
try {
List l = new DbConnection().search(sql);
session.setAttribute("list",l);
RequestDispatcher rd = request.getRequestDispatcher("/index.jsp"

;
rd.forward(request,response);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
这是bean中的代码
/////////////////////////////////////////////////
public List search(String sql) throws Exception{
System.out.println(sql);
ArrayList al = new ArrayList();
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
DataBean db = new DataBean();
db.setTitle(rs.getString("title"

);
al.add(db);
}
return al;
}