Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-941

prepareStatement with a closed connection

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            JP95 John Pace
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.