Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: Karen Goh <karenworld(at)yahoo(dot)com>
Cc: pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject: Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
Date: 2019-09-04 05:13:03
Message-ID: B3FFC2E6-0BBC-41F5-863B-396417CB0FDF@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

> On Sep 3, 2019, at 9:38 PM, Karen Goh <karenworld(at)yahoo(dot)com> wrote:
>
> Sure.
> I tried various ways to see if there is any mistakes. Still, I get the same old error :(
>
> Very difficult to type in Yahoo mail now...so I am continuing here (after you read the last sentence of the mail)
>
> So, even if I remove the System.out.print...it still gives me the error...
>
> Could it be Tomcat problem ? because I remove the page forwarded lines all altogether and it gave me the same old error as per not positioned properly, blah ...
>
> org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
> at org.postgresql.jdbc.PgResultSet.checkResultSet(PgResultSet.java:2772)
> at org.postgresql.jdbc.PgResultSet.getInt(PgResultSet.java:2052)
> at org.postgresql.jdbc.PgResultSet.getInt(PgResultSet.java:2485)
> at Controller.searchController.doPost(searchController.java:117)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
> at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
> at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
> at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
> at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
> at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
> at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> at java.lang.Thread.run(Thread.java:748)
>
> And below the line that is giving problem :
> subjList.add(rs.getString("subject_name"));
> newSub.addAll(subjList);
>
> System.out.println( "tutor ID=" + rs.getInt("tutor_id") + "zipcode =" + rs.getString("zipcode") +
> "subjectName=" + rs.getString("subject_name") + "tutorContact=" +
> rs.getString("tutor_contact_no"));
> }}
> I now inserted it before the close bracket of resultset.
>
> It points to System.out.print
>
Is "Controller.searchController.doPost(searchController.java:117)” your code? Do you in fact call rs.next() appropriately?
Also unless there’s a subjList = new List<> (or subjList.clear()) somewhere nearby you may be adding the contents of subjList more than once. There’s not enough of your code here to tell for sure exactly what’s going on.

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Karen Goh 2019-09-04 05:58:31 Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
Previous Message Karen Goh 2019-09-04 03:38:01 Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.