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 1i5PnR-0008M1-3h for pgsql-jdbc@arkaria.postgresql.org; Wed, 04 Sep 2019 07:33:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i5PnP-0003yY-P0 for pgsql-jdbc@arkaria.postgresql.org; Wed, 04 Sep 2019 07:33:39 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i5PnP-0003r3-Ck for pgsql-jdbc@lists.postgresql.org; Wed, 04 Sep 2019 07:33:39 +0000 Received: from sonic317-34.consmr.mail.ne1.yahoo.com ([66.163.184.45]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i5PnM-0005SS-Ja for pgsql-jdbc@lists.postgresql.org; Wed, 04 Sep 2019 07:33:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1567582415; bh=o1EjnsTG0CzsytfK8u99kaKVUXj2pSPEQYRx0vwvKgc=; h=Date:From:To:In-Reply-To:References:Subject:From:Subject; b=eTrlfLzgEFUt2WIWlLhamLb3S4+Tm1Fm7bW5+rTQEdml1+b8wi9+ON9Cm+2yzjZrHWVmVCpJK17Enxd/aG64kWUf7FiqH6qMKryS61nVb3IU2bZEr+KneQXX0wd3+R+YBEjCeL7fRXNZ/LRuXDGDiFskWp2X6LBumf0LNf4xCuY6LtQ4CjFTolYg7RDyyO89OmrHjNjLniULjUOTikNygQ0r81hX95FpOmOsH5rEmPv2e4FzifDlqG7THN/l5uTgCLySo8Cib+CXp5ez2UE8p6RwLQ6G4FJnFyoumsZ7wo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WWwA.yKO3uwOgNx76hvZbQ5iofvD 3O8g8Y6LdTze0NEi3QIQWuOM6Bf0GrS_RUcBCBp6KJuPp3Mogj3qkH3une58ut8m7cIMby81FDjm pzXS2Kv0n_cJOYEGRrcDQnlUNtyXA1NtNCr1Q5_pqpugoyNfJzdOJu9YSWte0F9ZW1fX.RJdyWym 6H7njxZN4kgpe.1udhHOhuEalaHcgFHa8NPXOfyivFT6CwLlBTC1pwlEcD.j9zyBhooIcdyp8nU6 KbY8oXSGkTHQkA.uR6NduW7i08oRL00KbB4yx0mKrX_tAZG3sxcVy8T_7Qw12wg-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic317.consmr.mail.ne1.yahoo.com with HTTP; Wed, 4 Sep 2019 07:33:35 +0000 Date: Wed, 4 Sep 2019 07:33:33 +0000 (UTC) From: Karen Goh To: pgsql-jdbc@lists.postgresql.org, Mark Rotteveel Message-ID: <1705600642.1365952.1567582413285@mail.yahoo.com> In-Reply-To: <8b79560c-3108-af04-e74f-f4fb55aa0624@lawinegevaar.nl> 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> <8b79560c-3108-af04-e74f-f4fb55aa0624@lawinegevaar.nl> 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_1365951_1224002830.1567582413283" Content-Length: 7491 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_1365951_1224002830.1567582413283 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Here's the entire code again: String[] subjectNames = request.getParameterValues("txtsubjects"); > > String zipcode = request.getParameter("location"); > > List subjList = new ArrayList(Arrays.asList(subjectNames)); > > List myList = new ArrayList<>(); > > ArrayList subList = new ArrayList<>(); > > CopyOnWriteArrayListnewSub = new CopyOnWriteArrayList(); > > tutor t = new tutor(); > > > > > > String sql1 = "select t.tutor_contact_no, t.zipcode, t.tutor_id, t2.subject_name FROM s_tutor t JOIN tutor_subject t2 ON t.tutor_id = t2.tutor_id where t.zipcode = ? And t2.subject_name = Any((?))"; > > > > PreparedStatement ps2 = connection.prepareStatement(sql1); > > ps2.setString(1, zipcode); > > for (int i = 0; i < subjectNames.length; i++) { > > Array array = connection.createArrayOf("text", subjList.toArray()); > > ps2.setArray(2, array); > > } > > ResultSet rs = ps2.executeQuery(); > > while (rs.next()) { > > t.setContactNo(rs.getString("tutor_contact_no")); > > t.setZipcode(rs.getString("zipcode")); > > t.settutor_id(rs.getInt("tutor_id")); > >for (String : subjList) even if i used subList.add(rs.get("mycolumnNameforthesubjects") And then I used a system.out.println here to print out all the id, contact No, zipcode and subjects name and then according to the stacktrace error, the System.out.println is the line that has the error - ResultSet not positioned properly, perhaps you need to call next. Basically, I have removed the setAttributes lines and simply replace it with a System out line (which I had earlier used it to see the print-out and it worked before so am not sure why it is not working this time round) to make it easier to diagnose what has gone wrong.... It could be due to Tomcat as yesterday I was trying to find out the issue but again and again, even after cleaning Tomcat directory before I run the code, even with certain lines already taken off, it shows me things that are not supposed to be there... On Wednesday, September 4, 2019, 3:14:00 PM GMT+8, Mark Rotteveel wrote: On 4-9-2019 07:58, Karen Goh wrote: > Hi Rob, > > I find the way you asked me if it is my 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 error ! With "your code", Rob was referring to the code you posted in your initial email. He was asking you to confirm that the code you posted earlier indeed contains the line Controller.searchController.doPost(searchController.java:117 Better would even be to explicitly point out the specific line in the code (with context). It is very hard to diagnose a problem based on an error and a snippet of code without context. Mark -- Mark Rotteveel ------=_Part_1365951_1224002830.1567582413283 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Here's the entire code again:

String[] sub= jectNames =3D request.getParameterValues("txtsubjects");
> = > String zipcode =3D request.getParameter("location");
>= > List<String> subjList =3D new ArrayList<String>(Arrays.as= List(subjectNames));
> > List<tutor> myList =3D new ArrayLi= st<>();
> > ArrayList<String> subList =3D new ArrayLis= t<>();
> > CopyOnWriteArrayList<String>newSub =3D new = CopyOnWriteArrayList<String>();
> > tutor t =3D new tutor();=
> >
> >
> > String sql1 =3D "select t.tut= or_contact_no, t.zipcode, t.tutor_id, t2.subject_name FROM s_tutor t JOIN t= utor_subject t2 ON t.tutor_id =3D t2.tutor_id where t.zipcode =3D ? And t2.= subject_name =3D Any((?))";
> >
> > PreparedStateme= nt ps2 =3D connection.prepareStatement(sql1);
> > ps2.setString(1,= zipcode);
> > for (int i =3D 0; i < subjectNames.length; i++) = {
> > Array array =3D connection.createArrayOf("text", s= ubjList.toArray());
> > ps2.setArray(2, array);
> > }
= > > ResultSet rs =3D ps2.executeQuery();
> > while (rs.next(= )) {
> > t.setContactNo(rs.getString("tutor_contact_no"= ));
> > t.setZipcode(rs.getString("zipcode"));
> = > t.settutor_id(rs.getInt("tutor_id"));
> >for (Stri= ng : subjList)
even if i used subList.add(rs.get("mycolumnNameforth= esubjects")
And then I used a system.out.println here to print out = all the id, contact No, zipcode and subjects name
and then according to = the stacktrace error, the System.out.println is the line that has the error= - ResultSet not positioned properly, perhaps you need to call next.

Basically, I have removed the setAttributes lines and simply replace i= t with a System out line (which I had earlier used it to see the print-out = and it worked before so am not sure why it is not working this time round)<= br> to make it easier to diagnose what has gone wrong....

It could b= e due to Tomcat as yesterday I was trying to find out the issue but again a= nd again, even after cleaning Tomcat directory before I run the code, even = with certain lines already taken off, it shows me things that are not suppo= sed to be there...

=
On Wednesday, September 4= , 2019, 3:14:00 PM GMT+8, Mark Rotteveel <mark@lawinegevaar.nl> wrote= :

=
On 4-9-2019 07:58, Karen Go= h wrote:
> Hi Rob,
>
> I find the way you asked me if it is my code very strange and w= hy 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 error !

With "y= our code", Rob was referring to the code you posted in your
initial email. He was asking you to confirm that the code you posted earlier indeed contains the line

Controller.searchController.doPost= (searchController.java:117


Bette= r would even be to explicitly point out the specific line in the
code (with context).

It is v= ery hard to diagnose a problem based on an error and a snippet of
code without context.

Mark--
Mark Rotteveel



------=_Part_1365951_1224002830.1567582413283--