WorM
WorM

Reputation: 1155

BasicDataSource close() method does not close connections

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 ?

Upvotes: 1

Views: 3822

Answers (1)

ekesken
ekesken

Reputation: 68

closing connection before closing datasource worked for me:

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

Upvotes: 2

Related Questions