In addition to the rest of the thread safety comments, there is also the issue of parallelization. In your case, you will not be able to open several database connections at the same time, and you will not be able to execute several queries with parallels, even if the safety of the result streams is not a problem.
So, I agree with others, do not make a static class out of it.
Creating a static class may be convenient, but creating new instances of it will probably not be an expensive operation, so itβs probably not so much as to improve performance.
Edit:
I noticed in a comment that you want to use your class on a website. In this case, you REALLY should not do this. With a static database class, you can safely serve one query at any time, and that is not what you want.
Rune grimstad
source share