Re: SQLException from Postgres JDBC

From: Peter Mount <peter(at)retep(dot)org(dot)uk>
To: Daniel Gayo Avello <danielgayo(at)terra(dot)es>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: SQLException from Postgres JDBC
Date: 2000-09-28 16:00:14
Message-ID: Pine.LNX.4.21.0009281657510.430-100000@maidast.demon.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Thu, 28 Sep 2000, Daniel Gayo Avello wrote:

> Hi, everybody! I've got a problem with Postgres JDBC driver and
> perhaps somebody could help me. I'm using JDK 1.2.2, JSK 2.0,
> PostgreSQL 7.0.2 and Apache JServ 1.1.2 and my servlets throw a
> SQLException when I try to perform a INSERT or DELETE operation...
>
> In fact, the operations are done but they don't return any results so
> a exception is catch by the servlet.
>
> Does somebody know the way to avoid this?

Which method are you using to perform the INSERT or DELETE?

You should be using executeUpdate() rather than executeQuery() because
executeUpdate() doesn't expect a ResultSet to be returned, and
executeQuery should throw an SQLException when it fails to get one.

An alternative (if you don't know what the query will be) is execute(),
but you then have to handle ResultGet accordingly.

Peter

--
Peter T Mount peter(at)retep(dot)org(dot)uk http://www.retep.org.uk
PostgreSQL JDBC Driver http://www.retep.org.uk/postgres/
Java PDF Generator http://www.retep.org.uk/pdf/

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Ken Kachnowich 2000-09-28 22:07:52 Re: Newlines in String inserts with JDBC
Previous Message Daniel Gayo Avello 2000-09-28 14:56:22 RE: SQLException from Postgres JDBC