Change the connection manager class to be autocloseable