세션을 사용하는 데 문제가 있습니다. view.jsp에서 사용자 이름과 암호를 가져 와서 포틀릿 클래스에 전달합니다. 그런 다음 데이터베이스에서 사용자 정보를 가져 와서 세션에 저장하고 "actionResponse.setRenderParameter ("jspPage ","/ patientInfo.jsp ")"명령을 사용하여 patientInfo.jsp로 이동합니다. 나는 사용자 정보를 다음 코드로 인쇄 :liferay 포틀릿에서 세션을 사용할 때 sql.exception 오류가 발생합니다.
<portlet:renderURL var="patientProfileURL">
<portlet:param name="jspPage" value="/patientProfile.jsp" />
</portlet:renderURL>
<a href="<%= patientProfileURL%>">Edit Profile</a></p>
모든 것이 지금까지 괜찮 :이 페이지에서
<%
ResultSet comments = (ResultSet)portletSession.getAttribute("comments");
ResultSet patientInfo = (ResultSet)portletSession.getAttribute("patientInfo");
patientInfo.next();
%>
<table>
<tr>
<th><strong>Patient Name</strong></th>
<th><strong>Insuline dose</strong></th>
</tr>
<tr>
<td class="info"><%=patientInfo.getString("FirstName") + patientInfo.getString("LastName")%></td>
<td class="info"><%=Integer.toString(patientInfo.getInt("InsulinDose"))%></td>
</tr>
이 patientProfile.jsp로가는 링크가있다. 그러나 patientProfile.jsp의 Backlink를 클릭하여 patientInfo.jsp로 돌아가서 다음 코드를 사용하면 스택 추적에서 "java.ethost.excqption : 결과가 끝난 후"오류가 발생하고 브라우저에서 "portlet is teprorily unavailable"오류가 발생합니다 :
<portlet:renderURL var="patientInfoURL">
<portlet:param name="jspPage" value="/patientInfo.jsp" />
</portlet:renderURL>
<p><a href="<%= patientInfoURL %>">Back</a></p>
이것은 데이터베이스에 연결하여 데이터베이스에서 데이터를 검색하는 방법입니다. java.lang.Class.forName (_jdbcDriver); connection = java.sql.DriverManager.getConnection (dbURL, dbUserName, dbPassword); Statement 명령문 = connection.createStatement(); resultSet = statement.executeQuery (sql); – Karadous
그렇게하지 마십시오. JDBC API에서 얻은 결과에 대해 오랫동안 보류하지 마십시오. 응용 프로그램의 확장 성이 제한되고 릴리스 될 수있는 리소스가 잠길 수 있습니다. 아마도 타임 아웃이나 - 알다시피 - 다른 문제를 일으킬 수도 있습니다. –