From: | Dave Cramer <pg(at)fastcrypt(dot)com> |
---|---|
To: | Hannes Erven <hannes(at)erven(dot)at> |
Cc: | List <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: executeQuery() throws "Statement has been closed" |
Date: | 2014-08-01 12:49:26 |
Message-ID: | CADK3HH+rp8jhcot_syE0MXD9Bh3_=m3cy9ZjsjSjsQGDO47U1A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
While it may be possible to share connections across threads, I am pretty
sure you cannot share Statements
Dave Cramer
dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
On 1 August 2014 04:43, Hannes Erven <hannes(at)erven(dot)at> wrote:
> Hi,
>
>
> > http://jdbc.postgresql.org/documentation/81/thread.html
>
> >
>
>> "If a thread attempts to use the connection while another one is using
>> it, it will wait until the other thread has finished its current
>> operation. If the operation is a regular SQL statement, then the
>> operation consists of sending the statement and retrieving any ResultSet
>> (in full)."
>>
>
>
> Consider this test case: one thread calls executeQuery("SELECT ..."), and
> while that query is still executing, a second thread calls close() on the
> statement.
>
> Given the documentation above, I would expect the regular SQL statement to
> complete, the statement then to be closed, and no exception thrown.
>
>
> I'll attach a sample code for this scenario. With the current git driver,
> this fails at getMaxRows().
>
> When you change Jdbc4Statement.createResultset() so it uses this.maxrows
> instead of getMaxRows() and hence skip checkClosed, then that test will
> pass. Patch also attached, although I have no idea whether this really is
> the right thing to do.
>
>
> Still, I will also check my code. I think this happens when a user closes
> a view while the data inside is (re)loading, so I'll probably have the
> error handling discard that exception in this case instead of ringing the
> alarm bell...
>
>
> Thanks for your comments, David and Kevin!
>
> Best regards,
>
> -hannes
>
From | Date | Subject | |
---|---|---|---|
Next Message | luke.henry | 2014-08-03 19:52:37 | BUG #11119: JDBC Driver misreports failing query/statement in executeBatch |
Previous Message | Hannes Erven | 2014-08-01 08:43:30 | Re: executeQuery() throws "Statement has been closed" |