Regarding # 1: No, because the answer you have will be immediately outdated (that is, if you have the answer “no database is locked”, someone else may come and immediately block it, leaving you bad information).
The right approach is to simply try your operation (optionally with a timeout) and see if it succeeds.
source share