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 1i5M7W-0007dX-IR for pgsql-jdbc@arkaria.postgresql.org; Wed, 04 Sep 2019 03:38:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i5M7U-0003fO-Tt for pgsql-jdbc@arkaria.postgresql.org; Wed, 04 Sep 2019 03:38:08 +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 1i5M7U-0003bB-FF for pgsql-jdbc@lists.postgresql.org; Wed, 04 Sep 2019 03:38:08 +0000 Received: from sonic313-15.consmr.mail.bf2.yahoo.com ([74.6.133.125]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5M7R-0007cj-Iw for pgsql-jdbc@lists.postgresql.org; Wed, 04 Sep 2019 03:38:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1567568282; bh=AW1DgJgCEE8nimF3PWmcyA1i3tYgM6AIs+kFow+6Mes=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From:Subject; b=cyItKWhceebjtX90KL8aD0qP0ZBvAQnEQWiEFeNiT+J+Dyzfle+gQl/hxUnB35PftASuBvhHkGkb3TIi9VIuIsbzSo7XCjqN4NI2goblBx3z0ndYBVoyq9Tpz7d0fU7z6P4nYyWw0/rHXmJf6JvYRaoUPg0wDjXHIXB0axilRaFjyCq3c8brYyYdRCcDSNmJx/p3xO4keMkWT3gXXtnZrJ1YJYNxYGw8CuBSnilBuJVlrLkD2KOWnBOELUMM8Rc4MTGDpVsXTrmkBVGJXIVbNTdYZnpOD5Vw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Tjjvc9dBL9G4LVVhuTQ429efTAPQvgSpuj7U14b8UYn 9VGfiOOboBczU2WMRql2EceY_RjWSCtntbr8uKsGfXc3cPz1awzHQkPwsJfJP.QZiru8pKGTdtja N5rT3Rkh5KJZB69_H5dMEHgi0PcyZMxub0Yr7S49ACyTbyRrUHvLdKPHO1OV3dNO1q0NYu9vZ8is 1XvtkFJYZit.4drFYE5IiidbfER9FTG.YrruPu718_24MSGbox.Tcu9nX2EtP9F.ZIEQugyMkwtV MdJSQcZ1jFpPrAHhO9h2nIsF0N3VZ_GjeKB7lxExw_YnBiQIo9dDdq1w- Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.bf2.yahoo.com with HTTP; Wed, 4 Sep 2019 03:38:02 +0000 Date: Wed, 4 Sep 2019 03:38:01 +0000 (UTC) From: Karen Goh To: Rob Sargent Cc: pgsql-jdbc@lists.postgresql.org Message-ID: <860006402.1322813.1567568281784@mail.yahoo.com> In-Reply-To: <1ACDE5B3-3F0E-4BF0-8C37-DAD09F35F30C@gmail.com> 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> Subject: Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next. MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1322812_202570668.1567568281782" Content-Length: 17401 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_1322812_202570668.1567568281782 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 y= ou 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, perha= ps 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(Applic= ationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil= terChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic= ationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil= terChain.java:166) at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFi= lter.java:71) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic= ationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil= terChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal= ve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVal= ve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticato= rBase.java:526) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav= a:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav= a:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccess= LogValve.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:4= 08) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight= .java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractPr= otocol.java:860) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoin= t.java:1587) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.= java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.ja= va:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.j= ava:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThre= ad.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); =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. It points to System.out.print =20 On Wednesday, September 4, 2019, 3:23:46 AM GMT+8, Rob Sargent wrote: =20 =20 Well we=E2=80=99ll need to see the stacktrace from the exception and proof= (line numbers) that the exception is in the code you sent. > On Sep 2, 2019, at 11:15 PM, Karen Goh wrote: >=20 >=20 >=20 > Hi Rob, >=20 > I am still getting the same type of error even if I store it in another L= ist...=20 >=20 > CopyOnWriteArrayList subList =3D new CopyOnWriteArrayList<>();=20 >=20 > subList.add(rs.getString("subject_name")); // note: using a new List >=20 > Are there anybody experienced Java developer that can help ? >=20 >=20 > On Tuesday, September 3, 2019, 9:12:34 AM GMT+8, Rob Sargent wrote: >=20 >=20 >=20 >=20 > > On Sep 2, 2019, at 12:28 AM, Karen Goh wrote: > > > > Hi experts, > > > > I have been trying to find a solution in the internet but there is only= 1 solution offered by stackoverflow in which the user uses if it is not th= ere then use a else to print out there is no more data/row that appeared in= that column. > > > > Basically, I was trying to get a List which meet certain search= condition so the data will come from 2 tables - one of which is a column f= rom a join table and the List falls under this table. > > > > So, here's the code that I attempt to get the data out but keep getting= ResultSet not positioned properly. > > > > String[] subjectNames =3D request.getParameterValues("txtsubjects"); > > String zipcode =3D request.getParameter("location"); > > List subjList =3D new ArrayList(Arrays.asList(subjectNa= mes));=20 > > List myList =3D new ArrayList<>(); > > ArrayList subList =3D new ArrayList<>(); > > CopyOnWriteArrayListnewSub =3D new CopyOnWriteArrayList= (); > > tutor t =3D new tutor(); > > > >=20 > > String sql1 =3D "select t.tutor_contact_no, t.zipcode, t.tutor_id, t2.s= ubject_name FROM s_tutor t JOIN tutor_subject t2 ON t.tutor_id =3D t2.tutor= _id where t.zipcode =3D ? And t2.subject_name =3D Any((?))"; > >=20 > > PreparedStatement ps2 =3D connection.prepareStatement(sql1); > > ps2.setString(1, zipcode); > > for (int i =3D 0; i < subjectNames.length; i++) { > > Array array =3D connection.createArrayOf("text", subjList.toArray()); > > ps2.setArray(2, array); > > } > > ResultSet rs =3D ps2.executeQuery(); > > while (rs.next()) {=20 > > t.setContactNo(rs.getString("tutor_contact_no"));=20 > > t.setZipcode(rs.getString("zipcode")); > > t.settutor_id(rs.getInt("tutor_id"));=20 > > > >=20 > > for (String s: subjList) > > if (s.contains(rs.getString("subject_name"))) >=20 > Are you sure you want to add to the subList you=E2=80=99re iterating thro= ugh? >=20 > > subjList.add(rs.getString("subject_name")); > > newSub.addAll(subjList); > > } > > myList.add(t);=20 > > request.setAttribute("tutors", myList);=20 > > request.setAttribute("sub", newSub);=20 > > > > Please. I hope someone can tell me what's wrong with the code or how to= overcome this error...I have been struggling for 2 weeks already. > > > > Thanks. > > } > > myList.add(t);=20 > > request.setAttribute("tutors", myList);=20 > > request.setAttribute("sub", newSub); > > > > > > >=20 >=20 =20 ------=_Part_1322812_202570668.1567568281782 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Sure.
I tried various ways to see if there is any m= istakes. 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 senten= ce 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.PSQLExc= eption: ResultSet not positioned properly, perhaps you need to call next.=09at org.postgresql.jdbc.PgResultSet.checkResultSet(PgResultSet.java:277= 2)
=09at org.postgresql.jdbc.PgResultSet.getInt(PgResultSet.java:2052)=09at org.postgresql.jdbc.PgResultSet.getInt(PgResultSet.java:2485)
= =09at Controller.searchController.doPost(searchController.java:117)
=09a= t javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
=09at jav= ax.servlet.http.HttpServlet.service(HttpServlet.java:741)
=09at org.apac= he.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterC= hain.java:231)
=09at org.apache.catalina.core.ApplicationFilterChain.doF= ilter(ApplicationFilterChain.java:166)
=09at org.apache.tomcat.websocket= .server.WsFilter.doFilter(WsFilter.java:53)
=09at org.apache.catalina.co= re.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)=
=09at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicat= ionFilterChain.java:166)
=09at org.apache.logging.log4j.web.Log4jServlet= Filter.doFilter(Log4jServletFilter.java:71)
=09at org.apache.catalina.co= re.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)=
=09at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicat= ionFilterChain.java:166)
=09at org.apache.catalina.core.StandardWrapperV= alve.invoke(StandardWrapperValve.java:202)
=09at org.apache.catalina.cor= e.StandardContextValve.invoke(StandardContextValve.java:96)
=09at org.ap= ache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java= :526)
=09at org.apache.catalina.core.StandardHostValve.invoke(StandardHo= stValve.java:139)
=09at org.apache.catalina.valves.ErrorReportValve.invo= ke(ErrorReportValve.java:92)
=09at org.apache.catalina.valves.AbstractAc= cessLogValve.invoke(AbstractAccessLogValve.java:678)
=09at org.apache.ca= talina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
=09a= t org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:34= 3)
=09at org.apache.coyote.http11.Http11Processor.service(Http11Processo= r.java:408)
=09at org.apache.coyote.AbstractProcessorLight.process(Abstr= actProcessorLight.java:66)
=09at org.apache.coyote.AbstractProtocol$Conn= ectionHandler.process(AbstractProtocol.java:860)
=09at org.apache.tomcat= .util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
=09at= org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.jav= a:49)
=09at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool= Executor.java:1149)
=09at java.util.concurrent.ThreadPoolExecutor$Worker= .run(ThreadPoolExecutor.java:624)
=09at org.apache.tomcat.util.threads.T= askThread$WrappingRunnable.run(TaskThread.java:61)
=09at java.lang.Threa= d.run(Thread.java:748)

And below the line that is giving problem :subjList.add(rs.getString("subject_name"));
newSub.addAll(s= ubjList);

System.out.println( "tutor ID=3D" + rs.getInt(&= quot;tutor_id") + "zipcode =3D" + rs.getString("zipcode= ") +
=09=09=09=09=09=09"subjectName=3D" + rs.getString(&q= uot;subject_name") + "tutorContact=3D" +
=09=09=09=09=09= =09rs.getString("tutor_contact_no"));
}}
I now inserted it= before the close bracket of resultset.

It points to System.out.prin= t

=09=09



=
On Wednesday, Septem= ber 4, 2019, 3:23:46 AM GMT+8, Rob Sargent <robjsargent@gmail.com> wr= ote:


Well we=E2=80=99ll need = to see the stacktrace from the exception and proof (line numbers) that the = exception is in the code you sent.


> On Sep = 2, 2019, at 11:15 PM, Karen Goh <karenworld@yahoo.co= m> wrote:
>
>
>
> Hi Rob,
>
> I am still getting the same type of error even if I stor= e it in another List...
>
> Cop= yOnWriteArrayList<String> subList =3D new CopyOnWriteArrayList<>= ;();
>
> subList.add(rs.getStri= ng("subject_name")); // note: using a new List
>
> Are there anybody experienced Java developer that can he= lp ?
>
>
>= On Tuesday, September 3, 2019, 9:12:34 AM GMT+8, Rob Sargent <robjsargent@gmail.com> wrote:
> <= br clear=3D"none">>
>
>
> > On Sep 2, 2019, at 12:28 AM, Karen Goh <karenworld@yahoo.com> wrote:
> >= ;
> > Hi experts,
> >
> > I have been trying to find a solution in the interne= t but there is only 1 solution offered by stackoverflow in which the user u= ses if it is not there then use a else to print out there is no more data/r= ow that appeared in that column.
> >
> > Basically, I was trying to get a List<String> which mee= t certain search condition so the data will come from 2 tables - one of whi= ch is a column from a join table and the List<String> falls under thi= s table.
> >
> > So, here's= the code that I attempt to get the data out but keep getting ResultSet not= positioned properly.
> >
> &g= t; String[] subjectNames =3D request.getParameterValues("txtsubjects");
> > String zipcode =3D request.getParameter("location"= );
> > List<String> subjList =3D new ArrayLis= t<String>(Arrays.asList(subjectNames));
> > = List<tutor> myList =3D new ArrayList<>();
>= ; > ArrayList<String> subList =3D new ArrayList<>();
> > CopyOnWriteArrayList<String>newSub =3D new CopyO= nWriteArrayList<String>();
> > tutor t =3D ne= w tutor();
> >
> >
> > String sql1 =3D "select t.tutor_contact_no, t.zipcode,= t.tutor_id, t2.subject_name FROM s_tutor t JOIN tutor_subject t2 ON t.tuto= r_id =3D t2.tutor_id where t.zipcode =3D ? And t2.subject_name =3D Any((?))= ";
> >
> > PreparedStateme= nt ps2 =3D connection.prepareStatement(sql1);
> > p= s2.setString(1, zipcode);
> > for (int i =3D 0; i &= lt; subjectNames.length; i++) {
> > Array array =3D= connection.createArrayOf("text", subjList.toArray());
&g= t; > ps2.setArray(2, array);
> > }
> > ResultSet rs =3D ps2.executeQuery();
> = > while (rs.next()) {
> > t.setContactNo(rs.get= String("tutor_contact_no"));
> > t.setZipcode(rs.g= etString("zipcode"));
> > t.settutor_id(rs.getInt("= tutor_id"));
> >
> >
> > for (String s: subjList)
> >= ; if (s.contains(rs.getString("subject_name")))
>
> Are you sure you want to add to the subList you=E2=80= =99re iterating through?
>
> >= ; subjList.add(rs.getString("subject_name"));
> > n= ewSub.addAll(subjList);
> > }
>= ; > myList.add(t);
> > request.setAttribute("tu= tors", myList);
> > request.setAttribute("sub", ne= wSub);
> >
> > Please. I h= ope someone can tell me what's wrong with the code or how to overcome this = error...I have been struggling for 2 weeks already.
> = >
> > Thanks.
> > }
> > myList.add(t);
> > request= .setAttribute("tutors", myList);
> > request.setAt= tribute("sub", newSub);
> >
> = >
> >
>
= >


<= /div>
------=_Part_1322812_202570668.1567568281782--