我無法從數據庫檢索值。請通過代碼,並引導我解決它無法從數據庫檢索值
public ArrayList getReqResInfo(String id)
{
String methodname="createConnection";
Connection conn = null;
ResultSet rs=null;
PreparedStatement psmt;
int req_id=0;
String reqid=id;
ArrayList resList=new ArrayList();
try {
conn = DBConnection.getJNDIConnection();
System.out.println("getReqResInfo id=="+reqid);
psmt= conn.prepareStatement("select * from CR_REQUEST_RESOURCE_INFO where REQUEST_ID=?");
psmt.setInt(1,Integer.parseInt(id));
rs= psmt.executeQuery();
System.out.println("getReqResInfo");
while(rs.next())
{
System.out.println(rs.getString("RES_LEVEL") +" " + rs.getString("NOOF_RES") +" " + rs.getString("RES_PRIMARY_SKILL") +" " + rs.getString("RES_QUALIFICATION") +" " + rs.getString("RES_SECONDARY_SKILL") +" " + rs.getString("RES_EXP"));
ReqResourceVO resourceVO=new ReqResourceVO();
resourceVO.setLevel(rs.getString("RES_LEVEL"));
resourceVO.setNumres(rs.getString("NOOF_RES"));
resourceVO.setPrimary(rs.getString("RES_PRIMARY_SKILL"));
resourceVO.setQualification(rs.getString("RES_QUALIFICATION"));
resourceVO.setSecondary(rs.getString("RES_SECONDARY_SKILL"));
resourceVO.setYear(rs.getString("RES_EXP"));
resList.add(resourceVO);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try {
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
return resList;
}
在下面所提到我調用這個函數的servlet
if(action.equals("view"))
{
try
{
String reqid=req.getParameter("id");
System.out.println("id "+reqid);
ReqProjVO reqProjVO=new ReqProjVO();
reqProjVO.setRequestid(reqid);
ReqResDAO reqresDAO=new ReqResDAO();
reqProjVO=reqresDAO.getReqProjInfo(reqProjVO);
ArrayList resVOList=reqresDAO.getReqResInfo(reqid);
req.setAttribute("projVO", reqProjVO);
HttpSession session = req.getSession(true);
session.setAttribute("resVOList", resVOList);
ReqProjDAO reqprojDAO=new ReqProjDAO();
ArrayList projList=reqprojDAO.Project();
req.setAttribute("projList", projList);
System.out.println("in request resource servlet");
RequestDispatcher rd= req.getRequestDispatcher("jsp/manager/RequestforResource.jsp");
rd.forward(req,res);
System.out.println("in request resource servlet");
}
catch(Exception e)
{
e.printStackTrace();
}
}
價值觀正在從數據庫中取出,並將其打印在控制檯上但它不會轉發到相關的JSP頁面,而是轉到JSP頁面中的日誌,並且我收到了這個巨大的錯誤。我不知道該怎麼辦......
java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at weblogic.utils.io.ChunkedOutputStream.writeTo(ChunkedOutputStream.java:193)
at weblogic.servlet.internal.ResponseHeaders.writeHeaders(ResponseHeaders.java:434)
at weblogic.servlet.internal.ServletResponseImpl.writeHeaders (ServletResponseImpl.java:1256)
at weblogic.servlet.internal.ServletOutputStreamImpl.sendHeaders(Servlet OutputStreamImpl.java:244)
at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:379)
at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469)
at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:304)
at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:139)
at weblogic.servlet.jsp.JspWriterImpl.write(JspWriterImpl.java:274)
at jsp_servlet._jsp._manager.__requestforresource._jspService(__requestforresource.java:237)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run (StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:408)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:318)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:505)
at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
at manager.RequestResourceServlet.doPost(RequestResourceServlet.java:181)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3498)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
我已經添加了servlet編碼請通過它並幫我解決這個問題。幾乎從昨天開始,我一直在努力... ... – Akshatha 2011-05-06 10:30:55
sop in while循環未在控制檯中打印爲什麼它如此....... – Akshatha 2011-05-06 10:32:22
如果仔細查看堆棧跟蹤,您調用的方法在你的'doPost()'方法中被稱爲'forward()',並且你在你的代碼中調用'rd.forward(req,res);'。我不是servlet的專家,但問題必須與調度員有關。 – BoffinbraiN 2011-05-06 10:59:35