Even I had the same problem, and here is the solution:
Your computer must be "ON" when connected to the database
If you provide a port number but are not using the Internet, this will not work.
However, if you do not specify a port number, and computer Internet is turned on, you should get an exit.
Here is the result without the Internet in one of my programs 
And here is the Internet connection

Also make sure that WIFI is turned on in the Genymotion emulator and its operation. You can verify this by opening a browser inside the emulator and opening any web page address.
Please comment if further assistance is required.
Suraj Dubey Mar 16 '14 at 5:45 2014-03-16 05:45
source share