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: rob stone <floriparob(at)gmail(dot)com>
Cc: Karen Goh <karenworld(at)yahoo(dot)com>, pgsql-jdbc(at)lists(dot)postgresql(dot)org, Mark Rotteveel <mark(at)lawinegevaar(dot)nl>
Subject: Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
Date: 2019-09-04 16:39:09
Message-ID: 1EC7278E-6842-4269-BCED-4238EFFF6562@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


> As I said last time, I'm not an "expert".
>
> subjectNames is declared as an array.
> In your "for" loop you will be doing ps2.setArray(2, array); multiple
> times depending on the number of subjects contained in subjectNames.
>
> I suspect the query is failing and as there is no try .. catch block to
> trap the SQLException, this is not reported back to your code.
>
> If you alter the postgresql.conf to log all SQL statements, restart,
> run your test again, look in the log file, it will show the passed
> parameter values. You can then verify that that the array passed as the
> second parameter is correct.
>
> HTH,
> Robert
Relieved am I that other’s could see that I was not doubting the OP wrote the code in question. I do consider myself a Java programmer (expert is a trickier question).

We do need to see the entire routine (I think that might be doPost()). If that’s more than 100 lines I suggest a refactor first. Have the doPost() call a method which does nothing but the desired interaction.

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Karen Goh 2019-09-05 01:48:29 Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.
Previous Message rob stone 2019-09-04 08:40:46 Re: how to resolve org.postgresql.util.PSQLException: ResultSet not positioned properly, perhaps you need to call next.