If it fails like described the service_name for the entry in the tnsnames.ora file is wrong.
I would make a copy of the tnsnames.ora file to a folder and rename the entry from ORCL to something unique for my test
oracle@befb83f389c6:~$ mkdir tst oracle@befb83f389c6:~$ cp
product/11.2.0/xe/network/admin/tnsnames.ora tst/
oracle@befb83f389c6:~$ vim tst/tnsnames.ora oracle@befb83f389c6:~$
cat tst/tnsnames.ora
tnsnames.ora Network Configuration File:
ONLYFORME = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = befb83f389c6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
) )
EXTPROC_CONNECTION_DATA = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
) )
at this point tnsping to the name ONLYFORME will fail as the client does not know about the copy of the tnsnames.ora file
oracle@befb83f389c6:~$ tnsping ONLYFORME
TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on
06-OCT-2018 12:18:51
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
TNS-03505: Failed to resolve name
to compensate we set the TNS_ADMIN env varaiable
oracle@befb83f389c6:~$ export TNS_ADMIN=/u01/app/oracle/tst/
oracle@befb83f389c6:~$ tnsping ONLYFORME
TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on
06-OCT-2018 12:19:16
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias Attempting to contact
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = befb83f389c6)(PORT =
1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE))) OK
(0 msec) oracle@befb83f389c6:~$
now tnsping to ONLYFORME works
connecting with sqlplus using this name also works fine
oracle@befb83f389c6:~$ sqlplus iasim@ONLYFORME
SQL*Plus: Release 11.2.0.2.0 Production on Sat Oct 6 12:22:43 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter password:
Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 -
64bit Production
SQL>
to reproduce the error youre getting we might put in an unknown service name
oracle@befb83f389c6:~$ cat tst/tnsnames.ora
tnsnames.ora Network Configuration File:
ONLYFORME = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = befb83f389c6)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = UNKNOWN_XE)
) )
EXTPROC_CONNECTION_DATA = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
) )
oracle@befb83f389c6:~$ sqlplus iasim@ONLYFORME
SQL*Plus: Release 11.2.0.2.0 Production on Sat Oct 6 12:25:17 2018
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter password: ERROR: ORA-12514: TNS:listener does not currently
know of service requested in connect descriptor
Enter user-name:
at this point we know which tnsnames.ora file it is that resolves the tnsname we're using (ONLYFORME) and we know where the error is
hope this helps...
ORCL=so your command should besqlplus username@ORCL- kfinity