I was getting the same error since 3 days. But it is solved now. I created a new object of the database whenever i want to connect to the database.
If i have 10 functions in database, i will call them with 10 different objects hence not giving me the error