菜鸟上路 请各位帮我看一下这个数据库调用好吗
我的目标是 调用数据库中的一个商品表 但是根本调不出来 得到的是商品是一个null
我的Servlet是:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
StringBuffer str = new StringBuffer();
ShowGoods sh = new ShowGoods();
HttpSession session = request.getSession(true);
session.setAttribute("s", sh);
try
{
Statement sta = dbcon.getcon().createStatement();
ResultSet rs = sta.executeQuery("select * from goods");
str = tablegoods.getTable(rs);
sh.setQueryResult(str);
}
catch(Exception e)
{
str.append(e);
}
RequestDispatcher dis = request.getRequestDispatcher("GoodsList.jsp");
dis.forward(request, response);
}
调用表的java是
public class tablegoods {
public static StringBuffer getTable(ResultSet rs) throws Exception
{
StringBuffer str = new StringBuffer();