From: | Glenn Holmer <shadowm(at)lyonlabs(dot)org> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Statement.ececuteUpdate() closes ResultSet obtained from same Statement |
Date: | 2014-08-24 14:50:11 |
Message-ID: | 53F9FBA3.8010109@lyonlabs.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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."
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2014-08-25 10:54:53 | Re: JDBC build broken by commit 9f9019b |
Previous Message | David G Johnston | 2014-08-24 14:11:57 | Re: Statement.ececuteUpdate() closes ResultSet obtained from same Statement |