I've got a short script opening datasource after which closing it. This script is applying BasicDataSource.

BasicDataSource bds = new BasicDataSource();
bds.setDriverClassName("com.mysql.jdbc.Driver");
bds.setUrl("jdbc:mysql://10.1.1.186:3306/logs");
bds.setUsername("root");
bds.setPassword("");
Connection connection = bds.getConnection();
System.err.println(connection);
bds.close();

Following the close() command works, after i try looking in mysql using "show full processlist" command I can tell the connection continues to be indexed by sleep status before the application is fully closed.

What shall we be held missing here ?

closing connection before closing datasource labored for me personally:

System.err.println(connection);
connection.close();
bds.close();