Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5lMj-0003zo-OM for pgsql-jdbc@arkaria.postgresql.org; Thu, 05 Sep 2019 06:35:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i5lMi-00076d-J7 for pgsql-jdbc@arkaria.postgresql.org; Thu, 05 Sep 2019 06:35:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5lMi-00076U-B2 for pgsql-jdbc@lists.postgresql.org; Thu, 05 Sep 2019 06:35:32 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5lMf-0005OK-AD for pgsql-jdbc@lists.postgresql.org; Thu, 05 Sep 2019 06:35:31 +0000 Received: by mail-pf1-x443.google.com with SMTP id 205so1066063pfw.2 for ; Wed, 04 Sep 2019 23:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=QTAttLviIfI4hee0VsmhR82nOF2CiPG8DyYNCXnjgss=; b=ZFLKcUwE2ovfVf+w5G43oPxzEUERgRhg8q0oLWJ/kLeHBoRfuNEvobT3vU6y3P0ZlB 7n/wYPpeWBwZl+51GiX2N/fGNaalYS/NeD3auJ0dySHR9lKihzVTPn5s5PZ7vZhwEQXL bY8AX597Hva6m7Dd4CRVu/OVKLDRcCMoICxKvTCEjOjzbdyh2WvOZf3ZxY/VKqzRvXRc 7XwD0WOSWQFgV2GdomFVxdQIVOUB1pqZ75WZgVS77GMORODUQkXbNnggpNRuoAkc3jE6 nJ5a0BElRfSXUiIcO568n2WBjiCoGgh1z8Q9LDOXo1zOEOC/0M8N3tuebpiiCNxqJBrK mk5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=QTAttLviIfI4hee0VsmhR82nOF2CiPG8DyYNCXnjgss=; b=KAhzlpRKOiyCEe88Ie9WxvXmkLQbXvm0mMJMKYcCrLUdqjphgA6pcjoR+n+ajrOKUW mx+7mK3fpj/UK3uvzjS52wKedY+aYZykywSsYERMbyoLUjCvSR9JybrZijKWO+SSIpcG Zlxhy0suA2A6NffBXNPg+HI9bRc/o+Tbgl6czq+X6PfwYKSDFnysFfo1eOeZMMa+KmWk UBmQwXU18+yCMc7XAXdbQXYCk/TPIJxcBUX452/8IEcRN58C0gniJpxk/ApyjfFmfZHL oBcPbZQHuqD92bFHysbpE139BT9nuzlnU3U5nqDgU8xVsYk1xZIkOq4trprR4yGBsK35 9f4g== X-Gm-Message-State: APjAAAUnb9e6JjOB+zfuTXJq7zOCjjH+4u4B8gu8LFx6zpepo0iLqujE 8bQsLxSCCZPmMvAd130IRap09huoURg= X-Google-Smtp-Source: APXvYqx9rWwgLaFn+kqjFIPi4sPDUqLVisM++b31VhDTBKeuys5EbxjTpyryioth/k7jaDtRgIFm6w== X-Received: by 2002:a65:4509:: with SMTP id n9mr1694465pgq.133.1567665326555; Wed, 04 Sep 2019 23:35:26 -0700 (PDT) Received: from [192.168.1.70] (d50-92-138-209.bchsia.telus.net. [50.92.138.209]) by smtp.gmail.com with ESMTPSA id p11sm1204551pff.136.2019.09.04.23.35.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Sep 2019 23:35:25 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-C2844BCA-430F-4B15-ACE7-F8B9B6472E61 Mime-Version: 1.0 (1.0) Subject: Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next. From: Rob Sargent X-Mailer: iPhone Mail (16G77) In-Reply-To: <1920437895.1671102.1567652395252@mail.yahoo.com> Date: Wed, 4 Sep 2019 23:35:25 -0700 Cc: Mikko Tiihonen , pgsql-jdbc@lists.postgresql.org Content-Transfer-Encoding: 7bit Message-Id: References: <932079842.712590.1567405714491@mail.yahoo.com> <58285538-686D-45F6-B5A5-883DBE7D0C10@gmail.com> <1422030722.958511.1567487705474@mail.yahoo.com> <1ACDE5B3-3F0E-4BF0-8C37-DAD09F35F30C@gmail.com> <860006402.1322813.1567568281784@mail.yahoo.com> <1829430979.1362196.1567576711470@mail.yahoo.com> <1920437895.1671102.1567652395252@mail.yahoo.com> To: Karen Goh List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-C2844BCA-430F-4B15-ACE7-F8B9B6472E61 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable After you address your Tomcat issue I would like to see the entire method na= med in the stack > On Sep 4, 2019, at 7:59 PM, Karen Goh wrote: >=20 >=20 > I have posted the full code already in my first email. What other parts do= you want to see. I am really puzzled about your question also..... >=20 > On Wednesday, September 4, 2019, 4:02:21 PM GMT+8, Mikko Tiihonen wrote: >=20 >=20 > Hi, >=20 > Rob is not being impolite. Asking to verify if it is your code is the most= polite thing he can do since you have not posted the full code you are runn= ing. > If the Controller would have been a 3rd party library code then Rob would h= ave had to pivot to searching what is wrong there. > In this case he made an educated guess and tried to propose further action= s based on it. >=20 > It would really help if you posted the full contents of the method that ob= tains the Result set and handles it. We are really searching for the rs.next= () call, as that is what the error message says is missing. > The two likely scenarios are: either it is missing from the code completel= y or you fail to call it again in a loop after each row. >=20 > -Mikko >=20 > From: Karen Goh > Sent: 04 September 2019 08:58 > To: Rob Sargent > Cc: pgsql-jdbc@lists.postgresql.org > Subject: Re: how to resolve org.postgresql.util.PSQLException: ResultSet n= ot positioned properly, perhaps you need to call next. > =20 > Hi Rob, >=20 > I find the way you asked me if it is my code very strange and why would yo= u say it is not my code, and I have been fighting every minute to resolve th= is and my head is pain with all these error ! >=20 > If you can't help me, the least you can is to own up you don't have the an= swer or refrain from saying something that is not RIGHT. >=20 > Thanks=20 > On Wednesday, September 4, 2019, 1:13:15 PM GMT+8, Rob Sargent wrote: >=20 >=20 >=20 >=20 > > On Sep 3, 2019, at 9:38 PM, Karen Goh wrote: > >=20 > > Sure. > > I tried various ways to see if there is any mistakes. Still, I get the s= ame old error :( > >=20 > > Very difficult to type in Yahoo mail now...so I am continuing here (afte= r you read the last sentence of the mail) > >=20 > > So, even if I remove the System.out.print...it still gives me the error.= .. > >=20 > > Could it be Tomcat problem ? because I remove the page forwarded lines a= ll altogether and it gave me the same old error as per not positioned proper= ly, blah ... > >=20 > > org.postgresql.util.PSQLException: ResultSet not positioned properly, pe= rhaps 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(Appl= icationFilterChain.java:231) > > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi= lterChain.java:166) > > at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53= ) > > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl= icationFilterChain.java:193) > > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi= lterChain.java:166) > > at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServlet= Filter.java:71) > > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl= icationFilterChain.java:193) > > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi= lterChain.java:166) > > at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV= alve.java:202) > > at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV= alve.java:96) > > at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica= torBase.java:526) > > at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j= ava:139) > > at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j= ava:92) > > at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAcce= ssLogValve.java:678) > > at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal= ve.java:74) > > at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav= a:343) > > at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java= :408) > > at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLig= ht.java:66) > > at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(Abstract= Protocol.java:860) > > at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpo= int.java:1587) > > at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBas= e.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(TaskTh= read.java:61) > > at java.lang.Thread.run(Thread.java:748) > >=20 > > And below the line that is giving problem : > > subjList.add(rs.getString("subject_name")); > > newSub.addAll(subjList); > >=20 > > System.out.println( "tutor ID=3D" + rs.getInt("tutor_id") + "zipcode =3D= " + rs.getString("zipcode") + > > "subjectName=3D" + rs.getString("subject_name") + "tutorContact=3D" + > > rs.getString("tutor_contact_no"));=20 > > }} > > I now inserted it before the close bracket of resultset. > >=20 > > It points to System.out.print >=20 > >=20 > Is "Controller.searchController.doPost(searchController.java:117)=E2=80=9D= your code? Do you in fact call rs.next() appropriately? > Also unless there=E2=80=99s a subjList =3D new List<> (or subjList.clear()= ) somewhere nearby you may be adding the contents of subjList more than once= . There=E2=80=99s not enough of your code here to tell for sure exactly wha= t=E2=80=99s going on. >=20 >=20 >=20 --Apple-Mail-C2844BCA-430F-4B15-ACE7-F8B9B6472E61 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Aft= er you address your Tomcat issue I would like to see the entire method named= in the stack

On Sep 4, 2019, at 7:59 PM, Karen Go= h <karenworld@yahoo.com> w= rote:

=
I have posted the full code already in my first email. What othe= r parts do you want to see. I am really puzzled about your question also...= ..

=
=
On Wednesday, September 4, 2019, 4:02:21 PM GMT= +8, Mikko Tiihonen <mikko.tii= honen@nitor.com> wrote:

Hi,

R= ob is not being impolite. Asking to verify if it is your code is the most po= lite thing he can do since you have not posted the full code you are running= .
If the Controller would ha= ve been a 3rd party library code then Rob would have had to pivot to searchi= ng what is wrong there.
In this case he made an= educated guess and tried to propose further actions based on it.

It would r= eally help if you posted the full contents of the method that obtains the Re= sult set and handles it. We are really searching for the rs.next() call, as t= hat is what the error message says is missing.
= The two likely scenarios are: either it is missing from the code completely o= r you fail to call it again in a loop after each row.

-= Mikko


From: Karen Goh <kar= enworld@yahoo.com>
Sent: 04 September 2019 0= 8:58
To: Rob Sargent <robjsargent@gmail.com>
Cc: pgsql-jdbc@lists.postgresql= .org <pgsql-jdbc@l= ists.postgresql.org>
Subject: Re: how to res= olve org.postgresql.util.PSQLException: ResultSet not positioned properly, p= erhaps you need to call next.
 
Hi Rob,=

I find the way you asked me if it is m= y code very strange and why would you say it is not my code, and I have been= fighting every minute to resolve this and my head is pain with all these er= ror !

If you can't help me, the least y= ou can is to own up you don't have the answer or refrain from saying somethi= ng that is not RIGHT.

Thanks
On Wednesday, September 4, 2019, 1:13:15 PM GMT+8, Rob Sar= gent <robjsargent@gmail.com&= gt; wrote:


=


> On Sep 3, 2= 019, at 9:38 PM, Karen Goh <karenworld@yahoo.com> wrote:
>
> Sure.
> I tried various ways to see if t= here is any mistakes. Still, I get the same old error :(
&= gt;
> Very difficult to type in Yahoo mail now...so I a= m continuing here (after you read the last sentence of the mail)
>
> So, even if I remove the System.out.prin= t...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 prop= erly, blah ...
>
> org.postgresql= .util.PSQLException: ResultSet not positioned properly, perhaps you need to c= all next.
> at org.postgresql.jdbc.PgResultSet.checkRes= ultSet(PgResultSet.java:2772)
> at org.postgresql.jdbc.= PgResultSet.getInt(PgResultSet.java:2052)
> at org.post= gresql.jdbc.PgResultSet.getInt(PgResultSet.java:2485)
>= at Controller.searchController.doPost(searchController.java:117)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)<= br clear=3D"none">> at javax.servlet.http.HttpServlet.service(HttpServlet= .java:741)
> at org.apache.catalina.core.ApplicationFil= terChain.internalDoFilter(ApplicationFilterChain.java:231)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicatio= nFilterChain.java:166)
> at org.apache.tomcat.websocket= .server.WsFilter.doFilter(WsFilter.java:53)
> at org.ap= ache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilter= Chain.java:193)
> at org.apache.catalina.core.Applicati= onFilterChain.doFilter(ApplicationFilterChain.java:166)
&g= t; at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFi= lter.java:71)
> at org.apache.catalina.core.Application= FilterChain.internalDoFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applica= tionFilterChain.java:166)
> at org.apache.catalina.core= .StandardWrapperValve.invoke(StandardWrapperValve.java:202)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardConte= xtValve.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.catali= na.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
> at org.apache.catalina.core.StandardEngineValve.invoke(St= andardEngineValve.java:74)
> at org.apache.catalina.con= nector.CoyoteAdapter.service(CoyoteAdapter.java:343)
> a= t 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.d= oRun(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.ThreadPoolExecuto= r$Worker.run(ThreadPoolExecutor.java:624)
> at org.apac= he.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=3D" + rs.getInt("tutor_id") + "zipc= ode =3D" + rs.getString("zipcode") +
> "subjectName=3D"= + rs.getString("subject_name") + "tutorContact=3D" +
>= 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)=E2=80=9D your code?  Do you in fact call rs= .next() appropriately?
Also unless there=E2=80=99s a subjL= ist =3D new List<> (or subjList.clear()) somewhere nearby you may be a= dding the contents of subjList more than once.  There=E2=80=99s not eno= ugh of your code here to tell for sure exactly what=E2=80=99s going on.



=
<= /div>
= --Apple-Mail-C2844BCA-430F-4B15-ACE7-F8B9B6472E61--