Using SqlService Connection Pool not closing

I am trying to use a Database in my upcoming plugin and found that Sponge has a service for that.

My problem is, that i can’t get it to close the HikariPools after the connection to the database. Its starting a new one each time.

Plugin source code: http://pastebin.com/gBdRjbeN

Server log: http://pastebin.com/JjA16q1y

Sponge Version: sponge-1.8-1371-2.1DEV-441

What am i doing wrong here?

Same “problem” here, ignored it, even after some thousand i notice no performance decrease.

Have this in 1.8-1371-2.1DEV-439 and 1.8-1371-2.1DEV-441.

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.

Why is no one using HikariCP?

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. :smile:

Probably because Sponge’s SqlService already uses HikariCP?

Nice to know :smile: