Why can't I establish a connection to the local oracle database from within the pre-built oracle virtual machine? I downloaded DeveloperDaysVM2016-06-02_13.ova from http://www.oracle.com/technetwork/database/enterprise-edition/databaseappdev-vm-161299.html and successfully loaded it into Virtual Box. 

I logged in as "oracle" user and I can see the desktop. 

From within the virtual machine, I opened Firefox and navigated to: 

http://localhost:8080/ords/hrrest/employees/ and successfully received a list of employees in JSON format. So I know the database is up and running. 

Now I am trying to connect to this database via the "ojdbc6.jar" Java connector/driver from Netbeans (see image below).  However, 

when I enter in

username:hr
password:oracle
SID:orcl12c
URL: jdbc:oracle:thin:@localhost:1521:orcl12c

I get an error message indicating 


  "Unable to add connection. Cannot establish a connection to
  jdbc:oracle:thin:@localhost:1521:orcl12c using
  oracle.jdbc.OracleDriver (ORA-01017: invalid username/password; logon
  denied"


But this doesn't make any sense because I was able to successfully login from the terminal: 

sqlplus hr

SQL*Plus: Release 12.1.0.2.0 Production on Thu Jul 7 17:21:07 2016

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Enter password: oracle
Last Successful login time: Thu Jul 07 2016 16:33:31 -04:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL&gt; 


Why can't I login via the java connector from netbeans? 

I also checked 

lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 07-JUL-2016 17:22:12

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                05-JUL-2016 16:48:08
Uptime                    2 days 0 hr. 34 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           orcl12c
Listener Parameter File   /u01/app/oracle/product/12.1.0.2/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/vbgeneric/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=vbgeneric)(PORT=8081))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl12c" has 2 instance(s).
  Instance "orcl12c", status UNKNOWN, has 1 handler(s) for this service...
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "orcl12cXDB" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
Service "ords" has 1 instance(s).
  Instance "orcl12c", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@vbgeneric oracle]$ 


So what am I doing wrong? Everything seems to be up and running correctly in this pre-built virtual machine.
This is the same story over and over again. Oracle uses the multitenant architecture in this VM and they set the environment variable TWO_TASK. This causes a lot of confusion.

When you connect as sqlplus hr, the value of TWO_TASK is automatically appended to the connection string, and you are connecting to SERVICE_NAME=ORCL and not SID=ORCL12 or SERVICE_NAME=ORCL12. The user hr was created in the ORCL pluggable database. With SID=ORCL12 or SERVICE_NAME=ORCL12, you connect to the root container, where this user does not exist, hence you receive the ORA-01017 error.



So instead of the connection string:

jdbc:oracle:thin:@localhost:1521:orcl12c

Use this for connecting:

jdbc:oracle:thin:@localhost:1521/orcl

Note the /orcl instead of :orcl12c. 

: specificies an instance connection (SID), while / speficies a service connection (SERVICE_NAME). You have to specify the service name when connecting to a pluggable database, because multiple pluggable databases share the same instance, and the name of the service is what differentiates them.