Re: Statement.ececuteUpdate() closes ResultSet obtained from same Statement - Mailing list pgsql-jdbc

From Glenn Holmer
Subject Re: Statement.ececuteUpdate() closes ResultSet obtained from same Statement
Date
Msg-id 53F9FBA3.8010109@lyonlabs.org
Whole thread Raw
In response to Statement.ececuteUpdate() closes ResultSet obtained from same Statement  (Christian Schlichtherle <christian@schlichtherle.de>)
List pgsql-jdbc
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."



pgsql-jdbc by date:

Previous
From: David G Johnston
Date:
Subject: Re: Statement.ececuteUpdate() closes ResultSet obtained from same Statement
Next
From: Craig Ringer
Date:
Subject: Re: JDBC build broken by commit 9f9019b