Singleton and Lock are 2 different concepts and are not interrelated. Lock acquire on object level but not on the class level. it does not matter that object is singleton object or normal object.
Singleton
In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. Please note singleton pattern will not apply lock on the object. For example 2 different threads are sharing the same single object reference and can call the different method on that single object simultaneously.
Lock
Lock means, we are restricting to access the same resource(object) by 2 different thread simultaneously. Java implemented the lock concept using the synchronized blocks or synchronized method.
Note : in your code example you are acquiring lock on the "lock" object (i.e. synchronized(lock) ) but not on the "db" object. To acquire lock on the db object you will have to change the code to
synchronized(db){
......
}