You cannot call
this
in a static method because
this
refers to the current class instance, and a static method is not associated with an instance.
There are two possible solutions; what's the best, depends on your application:
- Make
OpenConnection
static, and call it like a static method. - Make the caller an instance method.