Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XLZ7f-0003ZV-6n for pgsql-jdbc@arkaria.postgresql.org; Sun, 24 Aug 2014 14:50:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XLZ7e-0004zw-63 for pgsql-jdbc@arkaria.postgresql.org; Sun, 24 Aug 2014 14:50:22 +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 1XLZ7d-0004zc-5A for pgsql-jdbc@postgresql.org; Sun, 24 Aug 2014 14:50:21 +0000 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.229] helo=cdptpa-oedge-vip.email.rr.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XLZ7U-0006uC-T7 for pgsql-jdbc@postgresql.org; Sun, 24 Aug 2014 14:50:19 +0000 Received: from [184.58.196.239] ([184.58.196.239:54771] helo=[192.168.1.207]) by cdptpa-oedge01 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP id 93/6D-24565-3ABF9F35; Sun, 24 Aug 2014 14:50:11 +0000 Message-ID: <53F9FBA3.8010109@lyonlabs.org> Date: Sun, 24 Aug 2014 09:50:11 -0500 From: Glenn Holmer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Statement.ececuteUpdate() closes ResultSet obtained from same Statement References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 X-Pg-Spam-Score: -2.0 (--) 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 On 08/24/2014 07:33 AM, Christian Schlichtherle wrote: > I am not sure if this is a bug or a feature, but here it goes: > @Test(expected = SQLException.class) > public void testSharedStatementClosesResultSet() throws SQLException { > try (Connection c = getConnection(); > Statement s = c.createStatement()) { > try (ResultSet rs = s.executeQuery("SELECT a FROM test")) { > s.executeUpdate("INSERT INTO test(a) VALUES (1)"); > // Expected false, but throws SQLException: This statement has been closed. > assert !rs.next(); > } > } > } http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html "All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists." -- Glenn Holmer (Linux registered user #16682) "After the vintage season came the aftermath -- and Cenbe." -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc