pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karen Goh <karenworld@yahoo.com>
To: pgsql-jdbc@lists.postgresql.org, Mark Rotteveel <mark@lawinegevaar.nl>
Subject: Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
Date: Wed, 4 Sep 2019 07:33:33 +0000 (UTC)
Message-ID: <1705600642.1365952.1567582413285@mail.yahoo.com> (raw)
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>
	<B3FFC2E6-0BBC-41F5-863B-396417CB0FDF@gmail.com>
	<1829430979.1362196.1567576711470@mail.yahoo.com>
	<8b79560c-3108-af04-e74f-f4fb55aa0624@lawinegevaar.nl>

 Here's the entire code again:

 String[] subjectNames = request.getParameterValues("txtsubjects");
> > String zipcode = request.getParameter("location");
> > List<String> subjList = new ArrayList<String>(Arrays.asList(subjectNames)); 
> > List<tutor> myList = new ArrayList<>();
> > ArrayList<String> subList = new ArrayList<>();
> > CopyOnWriteArrayList<String>newSub = new CopyOnWriteArrayList<String>();
> > 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 <mark@lawinegevaar.nl> 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


  

view thread (21+ messages)  latest in thread

Message-ID: <1705600642.1365952.1567582413285@mail.yahoo.com>
Permalink:  ../1705600642.1365952.1567582413285@mail.yahoo.com/
Also on:    postgresql.org/message-id/1705600642.1365952.1567582413285@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: karenworld@yahoo.com, mark@lawinegevaar.nl
  Subject: Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
  In-Reply-To: <1705600642.1365952.1567582413285@mail.yahoo.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> <860006402.1322813.1567568281784@mail.yahoo.com> <B3FFC2E6-0BBC-41F5-863B-396417CB0FDF@gmail.com> <1829430979.1362196.1567576711470@mail.yahoo.com> <8b79560c-3108-af04-e74f-f4fb55aa0624@lawinegevaar.nl> <1705600642.1365952.1567582413285@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox