Re: sharing Connection object and SQLExceptions

From: "Michael Paesold" <mpaesold(at)gmx(dot)at>
To: "Steve Linabery" <slinabery(at)worldcycling(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: sharing Connection object and SQLExceptions
Date: 2002-08-28 17:22:16
Message-ID: 00b601c24eb7$75ca5050$0100a8c0@beeblebrox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Steve Linabery wrote:

> Hi,
>
> Another question from me today.
>
> So I had some java (1.4) code that shared a Connection object to do a
> transaction. There were no threading issues with the code in question;
> it was a case where one object created another using a live Connection
> in the second object's constructor. Then the first object made some
> method calls to the second object during an SQL transaction
> (db.setAutoCommitMode(false)).
>
> One of the methods in the second object was throwing an SQLException.
> It was trying to delete a table that did not exist.
>
> After some debugging, it appeared that something in the Connection went
> south after that error. Subsequently, if I created a Statement and
> tried to query a table in the database (*not* the one that the program
> had attempted to drop) I'd get another SQLException about the query
> returned no rows.
>
> Any thoughts on this one?
>
> Thank you,
> Steve Linabery

Have you checked connection.getWarnings() or statement.getWarnings()?
I suggest your problem is, that after dropping a non existent table,
the transaction is in ABORT mode, which means that any query will
fail until the next commit or rollback.

An example:

test=# begin;
BEGIN
test=# drop table non_existing;
ERROR: table "non_existing" does not exist
test=# select 1;
NOTICE: current transaction is aborted, queries ignored until end of
transaction block
*ABORT STATE*
test=#

Regards,
Michael Paesold

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Padraic Renaghan 2002-08-28 18:53:31 Batch Update updatecounts when error happens
Previous Message Steve Linabery 2002-08-28 17:04:04 sharing Connection object and SQLExceptions