消息关闭
    暂无新消息!
type Exception report

message

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.RuntimeException
com.tjy.utils.SqlHelper.executeQuery(SqlHelper.java:95)
com.tjy.service.UsersService.checkUser(UsersService.java:19)
com.tjy.controller.GoHallUI.doGet(GoHallUI.java:38)
com.tjy.controller.GoHallUI.doPost(GoHallUI.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.56 logs.

对应的错误行为:
SqlHelper.java:95:throw new RuntimeException(e.getMessage());
UsersService.java:19:ArrayList al=new SqlHelper().executeQuery(sql, parameters);
GoHallUI.java:38:if(usersService.checkUser(loginUser))
{
//说明用户合法,跳转购物大厅
request.getRequestDispatcher("/WEB-INF/hall.jsp").forward(request, response);

}
else
{
request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response);

}

GoHallUI.java:58: this.doGet(request,response);

2个回答

︿ 1
public ArrayList executeQuery(String sql,String []parameters){
ArrayList al=new ArrayList();
try{
ct=DBUtil.getConnection();
ps=ct.prepareStatement(sql);
//给sql的问号赋值
for(int i=0;i<parameters.length;i++){
ps.setString(i+1, parameters[i]);
}
rs=ps.executeQuery();
//这句话非常有用
ResultSetMetaData rsmd=rs.getMetaData();
//通过rsmd可以得到该结果集有多少列
int columnNum=rsmd.getColumnCount();
//循环的从al中取出数据,并封装到ArrayList中
while(rs.next()){
Object []objects=new Object[columnNum];
for( int i=0;i<objects.length;i++){
objects[i]=rs.getObject(i+1);
}
al.add(objects);
}
return al;
}catch(Exception e){
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}finally{
DBUtil.close(rs, ps, ct);
}
}