# Connect to Oracle Database that is hosted in a Virtual Machine from the host machine

Good day,

I've just setup a Virtual Machine (using VirtualBox) of Oracle Linux with Oracle Database in it. After setting it up, I can verify that I can connect to it using sqlplus (sqlplus of the Virtual Machine)

$sqlplus /nolog SQL*Plus: Release 11.2.0.1.0 Production on Sat Apr 21 14:32:48 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. SQL> conn myusername/mypassword Connected. SQL> select count(1) from my_table; COUNT(1) ---------- 73 SQL>  However, when I try to connect using JDeveloper from the Host Machine, I am getting Status : Failure - Test failed: IO Error: The Network Adapter could not established the connection. I tried connecting to other databases from our intranet from the JDeveloper of the Host Machine and they do succeed. Also, I tried turning off the iptables of the Virtual Machine (just in case). sudo /etc/init.d/iptables stop  So far though, nothing works. Any ideas? Thanks, Franz See EDIT: Update: I have just installed sqlplus on my host machine (note to others: instantclient 10.2.0.4.0 64bit does not work on mac. Use the 32-bit instead even if your mac is 64 bit like mine.), and I tried connecting to my oracle db in my virtual machine and it succeeded! However, I still cannot connect using JDeveloper. • On the virtual guest, see if there is anything listening on the standard Oracle Database port: sudo netstat --tcp --udp --listening --program | grep 1521 – Wesley Apr 21 '12 at 6:47 • @WesleyDavid I just ran it, nothing came up. – Franz See Apr 21 '12 at 7:29 • Exactly, nothing is listening therefore there is nothing to connect to. See my updated answer. – Wesley Apr 21 '12 at 7:31 ## 2 Answers On the machine that has sqlplus installed, in your case the host of the virtual machine, you need to set Oracle environmental variables before you can connect to other Oracle Database servers. For example: setenv ORACLE_SID orcl setenv ORACLE_HOME /u01/app/oracle/product/11.1.0/db_1 setenv LD_LIBRARY_PATH$ORACLE_HOME/lib:/usr/lib:/usr/dt/lib:/usr/openwin/lib:/usr/ccs/lib


You may have to manually create the admin folder and a tnsnames.ora file in that folder.

The process for connecting to a remote Oracle server is not a wizard driven one and takes some manual labor on your part. The help document linked to above will guide you through what you need for your specific environment.

## EDIT 1

Sorry, I think I understand things better now. Let's try something diff'rnt.

I think that the instance listener on the virtual machine is not listening on the IP address. On the virtual machine, go to the Net Services Administration page on the Oracle Enterprise Manager web interface. Edit the listener (LISTENER_localhost) and add a listener and select to use the IP address of the instance. Keep port 1521 as per default. You will be asked if you want to restart the service. Please do so. Then you should be able to connect from your host (or any other machine for that matter).

# EDIT 2

In JDeveloper, using the connection wizard on stop 3 of 4, use the Service Name, not the SID.

• Pardon, I am not quite sure I understand. A few clarifications on my question : a.) sqlplus is in my virtual machine and JDeveloper is in my host machine, b.) I can connect to the database using the sqlplus in my virtual machine but I cannot connect to it using the JDeveloper from my host machine, c.) I can connect to other oracle databases using my JDeveloper. – Franz See Apr 21 '12 at 7:07
• @user1343428 Updated my answer. – Wesley Apr 21 '12 at 7:28
• Pardon, where can i find that Net Services Administration from the Oracle Enterprise Manger web interface? – Franz See Apr 21 '12 at 8:42
• I am starting it up right now from the Oracle EM web interface. However, the listener start is still not finish (i started about 5minutes after my last comment here). Btw, how come when I do lsnrctl status, it says that my listener is READY? Also, I can telnet to my virtual machine's 1521 (i.e. telnet myvirtmach 1521) from both my virtual machine and from my host machine. Thoughts? – Franz See Apr 21 '12 at 9:00
• The listener startup is still not finish (weird). In the meantime, I installed sqlplus in my host machine. I tried connecting to my oracle database using sqlplus of my host machine and it worked! However, using JDeveloper, I still cannot connect to it. Thoughts? – Franz See Apr 21 '12 at 9:41

I've figured out what "Status : Failure - Test failed: IO Error: The Network Adapter could not established the connection." means. As it turns out, it couldn't establish the connection due to proxy configuration.