java.sql.SQLException: ResultSet.next가 호출되지 않았음

8월 05, 2012 12:57:58 오전 org.apache.catalina.core.StandardWrapperValve invoke
심각: Servlet.service() for servlet [jsp] in context with path [/JspProject] threw exception [An exception occurred processing JSP page /act12/member_info.jsp at line 50

47: <table border=”1″ width=”300″>
48: <tr align=”center”>
49: <td>아이디 : </td>
50: <td><%=rs.getString(“id”)%></td>
51: </tr>
52: <tr align=”center”>
53: <td>비밀번호 : </td>
Stacktrace:] with root cause
java.sql.SQLException: ResultSet.next가 호출되지 않았음
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:1107)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:424)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263)
at org.apache.jsp.act12.member_005finfo_jsp._jspService(member_005finfo_jsp.java:116)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

 

쿼리해온 결과에 접근하여 데이터를 불러오고 싶으면

rs.next() 를 호출해라…

커서를 첫 레코드 앞에 갔다놔야함. 한번만 해야지 또 호출하면 2번째 레코드로 가버린다.

 

[AS-IS]

rs = pstmt.executeQuery();

[TO-BE]

rs = pstmt.executeQuery();
rs.next(); // 쿼리결과 1행만 나올것이므로 커서 위치를 첫 레코드에 위치하게 해줌

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s