[CONJ-941] prepareStatement with a closed connection Created: 2022-03-11  Updated: 2022-04-25  Resolved: 2022-04-25

Status: Closed
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 2.7.1
Fix Version/s: 3.0.1-beta

Type: Bug Priority: Minor
Reporter: John Pace Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows 10, CentOS 7



 Description   

Hi,

I am using the MariaDB ConnectorJ to connect to a database. Since I had several nasty problems in the past, I created some tests with JUnit to test the database connection.

Since many versions of Connector/J this test fails, no exception is thrown (sorry, had no time to report it earlier):

	@Test
	public void constructorClosedConnection() throws SQLException {
		assertThrows(SQLException.class, () -> {
			Connection closedConnection = Database.getInstance().getConnection();
			closedConnection.rollback();
			closedConnection.close();
 
			closedConnection.prepareStatement("SELECT * FROM SampleTable");
		});
	}

The function Database.getInstance().getConnection() grabs a connection from the connection-pool and returns it. This issue is not important in production, but every time I run my tests this test fails, while it worked in the past.



 Comments   
Comment by Diego Dupin [ 2022-04-25 ]

closing, since corrected in 3.0 version

Generated at Thu Feb 08 03:19:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.