Added per-database connection lock