| От | Jeremy Buchmann |
|---|---|
| Тема | Re: "No results" exception on insert |
| Дата | |
| Msg-id | 3AF856EA.9030603@wellsgaming.com обсуждение |
| Ответ на | "No results" exception on insert (Brian_Williams@i2.com) |
| Список | pgsql-jdbc |
Brian_Williams@i2.com wrote:
> Hello,
>
> I have some code which is essentially doing the following:
>
> Statement stmt;
> ResultSet rs = stmt.executeQuery("insert into users values ( 'joe', 'blow'
> )");
>
> The values are inserted into the table correctly. I verified this using
> psql:
> "select * from users".
>
> The problem is that the executeQuery throws an Exception. The message
> is "No results were returned by the query":
>
> No results were returned by the query.
> at org.postgresql.jdbc2.Statement.executeQuery(Statement.java,
> Compiled
> Code)
Hi,
When you're using INSERT, UPDATE, or DELETE, you should use the
executeUpdate() method of JDBC. executeQuery expects results because it
assumes a query is being sent. :)
HTH,
Jeremy
В списке pgsql-jdbc по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера