Обсуждение: java.sql.Statement.isClosed() throws an SQLException if the statement is closed
java.sql.Statement.isClosed() throws an SQLException if the statement is closed
От
Christian Schlichtherle
Дата:
Hi, this bug applies to the JDBC driver version 9.3-1102-jdbc41. It only happens when using a PGPoolingDataSource. The bug isin the proxy class for the Statement. Here’s some test code to provide evidence: <pre><code> package cpssd.postgresql; import org.junit.Test; import org.postgresql.ds.PGPoolingDataSource; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; public class IsClosedIT { @Test(expected = SQLException.class) public void testIsClosed() throws SQLException { final PGPoolingDataSource ds = new PGPoolingDataSource(); ds.setDatabaseName("postgres"); try (Connection c = ds.getConnection()) { Statement s = c.createStatement(); s.close(); // Throws SQLException: Statement has been closed. assert s.isClosed(); } } } </code></pre> Regards, Christian Schlichtherle
Вложения
Re: java.sql.Statement.isClosed() throws an SQLException if the statement is closed
От
Christian Schlichtherle
Дата:
The bug likewise applies to PreparedStatement, not just Statement. Am 15.08.2014 um 13:43 schrieb Christian Schlichtherle <christian@schlichtherle.de>: > Hi, > > this bug applies to the JDBC driver version 9.3-1102-jdbc41. It only happens when using a PGPoolingDataSource. The bugis in the proxy class for the Statement. Here’s some test code to provide evidence: > > <pre><code> > package cpssd.postgresql; > > import org.junit.Test; > import org.postgresql.ds.PGPoolingDataSource; > > import java.sql.Connection; > import java.sql.SQLException; > import java.sql.Statement; > > public class IsClosedIT { > > @Test(expected = SQLException.class) > public void testIsClosed() throws SQLException { > final PGPoolingDataSource ds = new PGPoolingDataSource(); > ds.setDatabaseName("postgres"); > try (Connection c = ds.getConnection()) { > Statement s = c.createStatement(); > s.close(); > // Throws SQLException: Statement has been closed. > assert s.isClosed(); > } > } > } > </code></pre> > > Regards, > Christian Schlichtherle
Вложения
Re: java.sql.Statement.isClosed() throws an SQLException if the statement is closed
От
Dave Cramer
Дата:
Do you have a patch ?
On 15 August 2014 11:36, Christian Schlichtherle <christian@schlichtherle.de> wrote:
The bug likewise applies to PreparedStatement, not just Statement.
Am 15.08.2014 um 13:43 schrieb Christian Schlichtherle <christian@schlichtherle.de>:
> Hi,
>
> this bug applies to the JDBC driver version 9.3-1102-jdbc41. It only happens when using a PGPoolingDataSource. The bug is in the proxy class for the Statement. Here’s some test code to provide evidence:
>
> <pre><code>
> package cpssd.postgresql;
>
> import org.junit.Test;
> import org.postgresql.ds.PGPoolingDataSource;
>
> import java.sql.Connection;
> import java.sql.SQLException;
> import java.sql.Statement;
>
> public class IsClosedIT {
>
> @Test(expected = SQLException.class)
> public void testIsClosed() throws SQLException {
> final PGPoolingDataSource ds = new PGPoolingDataSource();
> ds.setDatabaseName("postgres");
> try (Connection c = ds.getConnection()) {
> Statement s = c.createStatement();
> s.close();
> // Throws SQLException: Statement has been closed.
> assert s.isClosed();
> }
> }
> }
> </code></pre>
>
> Regards,
> Christian Schlichtherle