Re: "No results" exception on insert

From: Jeremy Buchmann <jeremy(at)wellsgaming(dot)com>
To: Brian_Williams(at)i2(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: "No results" exception on insert
Date: 2001-05-08 20:28:26
Message-ID: 3AF856EA.9030603@wellsgaming.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Brian_Williams(at)i2(dot)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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2001-05-08 21:14:46 Re: MULTIBYTE and SQL_ASCII (was Re: [JDBC] Re: A bugwith pgsql 7.1/jdbc and non-ascii (8-bit) chars?)
Previous Message Mike D'Agosta 2001-05-08 20:02:05 Re: "No results" exception on insert