How to retrieve jsonb column through JDBC

Поиск
Список
Период
Сортировка
От Alexander Farber
Тема How to retrieve jsonb column through JDBC
Дата
Msg-id CAADeyWhNooe=vRm+8m6baTYg1uDEu3d5kfiNAnqDa1CrE3Dnig@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to retrieve jsonb column through JDBC  (Dave Cramer <pg@fastcrypt.com>)
Re: How to retrieve jsonb column through JDBC  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
Hello,

what do you use to retrieve a jsonb column using JDBC?

I have tried

        Object last_tiles = rs.getObject("last_tiles");

and the resulting Object seems to be a String.

Then I have called (using Jetty JSON class here):

         Object last_tiles = JSON.parse(rs.getString("last_tiles"));

And it seems to work ok... but I am still curious, what is the recommended (or maybe planned for future) way for retrieving jsonb data in Java.

Also

         List last_tiles = (List) JSON.parse(rs.getString("last_tiles"));

has not work for me even though the string is:

 [{"col": 7, "row": 8, "value": 1, "letter": "A"}, {"col": 7, "row": 7, "value": 2, "letter": "B"}, {"col": 7, "row": 9, "value": 2, "letter": "C"}]

but it is probably the problem of the Jetty class I am using and not of JDBC...

Regards
Alex


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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: a column definition list is required for functions returning "record"
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: How to retrieve jsonb column through JDBC