Thread: Re: SQLSTATE with pg74.1jdbc3.jar

Re: SQLSTATE with pg74.1jdbc3.jar

From
Moreno Mauri
Date:
Paul Thomas ha scritto:

> On 15/01/2004 14:50 Moreno Mauri wrote:
> > Hi all,
> > I'm a newbie in JDBC code.
> >
> > I tried to execute a Statement.executeUpdate() method to insert a
row
> > already present in my Postgresql DB.
> >
> > With JDBC I receive a SQLException but I would like to have
> > more informations about the error (something like Duplicate Key
> > Exception).
> >
> > I read that SQLException class have the getSQLState() method, but
> > when I call it, the result is null (the getErrorCode() return always
0).
>
> What version of PostgreSQL are you running? To get the error codes
> requires a 7.4 server.

This was really a newbie error: I'm using postgresql 7.2 !

I changed the driver (now is pgjdbc2.jar) but the problem
didn't disappear.

Thanks
Moreno

p.s. for Dennis Romero: I can't answer your question :-(




Re: SQLSTATE with pg74.1jdbc3.jar

From
Paul Thomas
Date:
On 15/01/2004 15:48 Moreno Mauri wrote:
> > What version of PostgreSQL are you running? To get the error codes
> > requires a 7.4 server.
>
> This was really a newbie error: I'm using postgresql 7.2 !
>
> I changed the driver (now is pgjdbc2.jar) but the problem
> didn't disappear.


versions of PG earlier than 7.4 don't supply error codes to the client (in
our case the JDBC driver). Using an earlier version of the driver does not
change this. You will need to use the latest driver _and_ update your
server to 7.4 to get access to the error codes.

HTH

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+