views:

44

answers:

1

Hello all,

I have a short script opening datasource and then closing it. This script is using 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();

After the close() command works, when I look in mysql using "show full processlist" command I can see that the connection is still listed in sleep status until the application is fully closed.

What am i missing here ?

+1  A: 

closing connection before closing datasource worked for me:

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