close database connections after each operation
use correct database connection
fix initialization of database connections