Re: how to resolve org.postgresql.util.PSQLException: ResultSet notpositioned properly, perhaps you need to call next.

Поиск
Список
Период
Сортировка
От Karen Goh
Тема Re: how to resolve org.postgresql.util.PSQLException: ResultSet notpositioned properly, perhaps you need to call next.
Дата
Msg-id 1705600642.1365952.1567582413285@mail.yahoo.com
обсуждение исходный текст
Ответ на Re: how to resolve org.postgresql.util.PSQLException: ResultSet notpositioned properly, perhaps you need to call next.  (Mark Rotteveel <mark@lawinegevaar.nl>)
Ответы Re: how to resolve org.postgresql.util.PSQLException: ResultSet notpositioned properly, perhaps you need to call next.  (Mark Rotteveel <mark@lawinegevaar.nl>)
Re: how to resolve org.postgresql.util.PSQLException: ResultSet notpositioned properly, perhaps you need to call next.  (rob stone <floriparob@gmail.com>)
Список pgsql-jdbc
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



В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Mark Rotteveel
Дата:
Сообщение: Re: how to resolve org.postgresql.util.PSQLException: ResultSet notpositioned properly, perhaps you need to call next.
Следующее
От: Mark Rotteveel
Дата:
Сообщение: Re: how to resolve org.postgresql.util.PSQLException: ResultSet notpositioned properly, perhaps you need to call next.