Why can't I establish a connection to the local oracle database from within the pre-built oracle 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.