basic java version of connection