Really throw ConnectionException on connection failure
Fix error when no connection opened

"pg_last_error(): No PostgreSQL link opened yet"