BasicDataSource close() method does not close connections
I have a short script ope开发者_开发知识库ning 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 ?
closing connection before closing datasource worked for me:
System.err.println(connection);
connection.close();
bds.close();
精彩评论