There are two classes, one testing the connection to the database, the other making entries to the database and reading from it. Each class has this code:
static Connection connection; @BeforeClass public static void init() { connection = DBconnector.getInstance().getConnection(); } @AfterClass public static void close() throws SQLException { connection.close(); } If you run these tests separately, then they work fine, but if you throw out the SQL, then the SQL exception No operations allowed after connection closed.
In my opinion, some kind of lag occurs when, after closing the connection, it is impossible to immediately open it again. It would be possible to integrate these two classes into one test, but as I read it would be a bad tone, each class should have its own test.
DBconnector, I suspect the problem is in it. - Roman