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."