That’s not an issue (I believe): When you call Connection.close() on a connection you got from the DataSource which you received from Sponge’s SQLService, the connection is not actually closed but returned to the connection pool that sources Sponge’s SQLService - that is what connection pooling is all about.Edit: I was wrong, see below.
I really recommend to read through the JDBC documentation on connection pools to understand what is going on.
yeah but if you spam it,it fills the ram rather quickly. And if you stop the server you can see how he has to show down every pool you ever opened. which can be a lot.
Well if i dont have any mistakes in my code, then i can live with it for now.
I need to correct myself. When writing the above answer, I assumed that we were talking about the creation of new connections, not of entirely new connection-pools. Indeed, a whole new pool is constructed whenever SqlService.getDataSource(String) is called, even when a pool already exists for this database and credentials. Obviously this is unintended behaviour.
When looking at the implementation it also becomes clear why this is happening (hint: What makes two objects equal in Java?). I already submitted a ticket for the issue.
Edit: The issue was fixed with one of the latest commits.