Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XCw6l-0002aM-6s for pgsql-jdbc@arkaria.postgresql.org; Thu, 31 Jul 2014 19:33:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XCw6k-0006Jt-J0 for pgsql-jdbc@arkaria.postgresql.org; Thu, 31 Jul 2014 19:33:46 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XCw6j-0006Jm-J9 for pgsql-jdbc@postgresql.org; Thu, 31 Jul 2014 19:33:45 +0000 Received: from chello080108195078.3.13.vie.surfer.at ([80.108.195.78] helo=margarita.erven.at) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XCw6f-0004cP-RE for pgsql-jdbc@postgresql.org; Thu, 31 Jul 2014 19:33:43 +0000 Received: from [192.168.27.166] (unknown [192.168.27.166]) by margarita.erven.at (Postfix) with ESMTPSA id 6F4C177000E0; Thu, 31 Jul 2014 21:33:36 +0200 (CEST) Message-ID: <53DA9A0B.6090404@erven.at> Date: Thu, 31 Jul 2014 21:33:31 +0200 From: Hannes Erven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Dave Cramer CC: List Subject: Re: executeQuery() throws "Statement has been closed" References: <53DA04A9.2030101@erven.at> <53DA50FF.2040803@erven.at> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.6 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Dave, > Sharing one connection across multiple hibernate sessions seems > fraught with danger ? sorry, I should have explained better. This is a read-only ("SELECT") workload, so there are no commits etc. interfering between threads. This is a session-per-view pattern so the indiviual sessions have minimal size and may be closed and garbage collected independently. Access to the backend is again pooled through a pgbouncer statement pool (which might be another place to look at). According to http://jdbc.postgresql.org/documentation/81/thread.html , JDBC connections are threadsafe and can be used by multiple threads concurrently. That page also reads, "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)." As I understand it, even if one thread closes the connection, a call to executeQuery() should either fail early or complete. It appears to me that is is not the case in these rare instances where the exception is thrown only when the results have already been processed successfully. As Kevin pointed out (thanks!), getMaxRows() is required by the spec to check whether the connection is still open. So let me rephrase the question: why is AbstractJdbc4Statement.createResultSet() calling getMaxResult() and friends [which in turn check for openness] instead of directly using the already prepared field values? In any case, I'll see if I can come up with a test case to demonstrate. Thanks again, best regards -hannes -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc