No results returned by the Query error in PostgreSQL

Ragesh Kr picture Ragesh Kr · Jan 22, 2014 · Viewed 33.4k times · Source

I am trying to insert a data into a table. After executing the query i am getting an exception stating

org.postgresql.util.PSQLException: No results were returned by the query.
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:284)

The data is getting inserted successfully, but i have no idea why i am getting this exception ??

Answer

Paul Draper picture Paul Draper · Jan 22, 2014

Use

executeUpdate

instead of

executeQuery

if no data will be returned (i.e. a non-SELECT operation).