Re: Moving from PHP to Java: A result was returned when none was expected.

Поиск
Список
Период
Сортировка
От Jan de Visser
Тема Re: Moving from PHP to Java: A result was returned when none was expected.
Дата
Msg-id 1478658.1ud16gO5Hr@coyote
обсуждение исходный текст
Ответ на Re: Moving from PHP to Java: A result was returned when none was expected.  (Alexander Farber <alexander.farber@gmail.com>)
Ответы Re: Moving from PHP to Java: A result was returned when none was expected.  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
On Wednesday, June 15, 2016 4:21:47 PM EDT Alexander Farber wrote:
> Hello Jan,
>
> On Wed, Jun 15, 2016 at 4:17 PM, Jan de Visser <jan@de-visser.net> wrote:
> > On Wednesday, June 15, 2016 3:56:07 PM EDT Alexander Farber wrote:
> > > Now I am trying to call the same function through JDBC driver
> >
> > 9.4.1208.jre7:
> > >     private static final String SQL_SKIP_GAME   =
> > >
> > >             "SELECT words_skip_game(?, ?)";
> > >
> > >         try (PreparedStatement st =
> > >
> > > mDatabase.prepareStatement(SQL_SKIP_GAME)) { st.setInt(1, mUid);
> > >
> > >             st.setInt(2, gid);
> > >             st.executeUpdate();
> > >
> > >         }
> > >
> > > and sadly get the SQLException "A result was returned when none was
> > > expected.".
> >
> > Looking at the 9.4 documentation, I see something completely different:
> >
> > https://jdbc.postgresql.org/documentation/94/callproc.html
>
> your doc talks about calling stored functions which return SETOF or cursor.

Example 6.1 doesn't.

What I was trying to indicate that the page you referred to has undergone, um,
significant changes over the years.

>
> But my function is returning VOID, so according to
> https://jdbc.postgresql.org/documentation/94/update.html
> I was thinking I should call executeUpdate()?
>
> Regards
> Alex

Point is that you're doing a SELECT. A SELECT returns a result, which can be
empty. I would use executeQuery and ignore the result.

There is a bit of a mismatch between the JDBC stored procedure model and the
pgsql function model, because pgsql doesn't have true stored procedures.




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

Предыдущее
От: Alexander Farber
Дата:
Сообщение: Re: Moving from PHP to Java: A result was returned when none was expected.
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Moving from PHP to Java: A result was returned when none was expected.