Oracle TNS alias connection works, ezconnect does not - oracle

Using sqlplus and a tns names alias, I can connect successfully:
sqlplus xxxxxx/yyyyyy#zzzzz
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Apr 17 15:48:14 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Sun Apr 17 2022 15:33:24 -04:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
I then took the tnsnames.ora entry:
tnsping zzzzz
TNS Ping Utility for 32-bit Windows: Version 19.0.0.0.0 - Production on 17-APR-2022 15:58:46
Copyright (c) 1997, 2019, Oracle. All rights reserved.
Used parameter files:
C:\app\client\product\19.0.0\client_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.domain.tld)(PORT = 1515)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = service.domain.tld)))
OK (50 msec)
and tried to connect using ezconnect syntax:
sqlplus xxxxx/yyyyyy#host.domain.tld:1515/service.domain.tld
SQL*Plus: Release 19.0.0.0.0 - Production on Sun Apr 17 16:01:13 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Which failed as you can see. I guess I'm missing something, but what?

Related

how to login to oracle express as a new user

I'm getting started with Oracle Express. I used sqlplus to connect and create a new user then tried to use it with the password I gave it. Got a login error (tried 3 times with password I set). I'm surely missing something simple! What is my problem here?
>.\sqlplus / as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Fri Apr 15 14:50:40 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
SQL> alter session set container = xepdb1;
Session altered.
SQL> alter user foo identified by bar
2 ;
User altered.
SQL> connect foo
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied
Check contents of TNSNAMES.ORA. "My" XE database (the same version as yours) has alias pdb1:
PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ods...r)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XEPDB1)
)
)
Then check SQLNET.ORA. "My" version looks like this (your should too, I'd say):
SQLNET.AUTHENTICATION_SERVICES= (NONE)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Now, at operating system command prompt:
c:\temp>sqlplus scott/tiger#pdb1
SQL*Plus: Release 21.0.0.0.0 - Production on Fri Apr 15 21:04:58 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Last Successful login time: Fri Apr 15 2022 21:02:33 +02:00
Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
SQL>
If foo is a local user, who exists only in container xepdb1, then the connect command should be connect foo#xepdb1. The connect command doesn't check to see where the user may exist (and indeed, different users by the same name may exist in different containers); you must include the container name in the command.
Perhaps you thought that, since you changed the container to xepdb1 (while connected as sysdba) already, the connect command would assume "within the same container". It does not.
Succeed with:
connect foo/bar#localhost:1521/xepdb1

How do I connect to sqlplus in bash script without editing the tnsnames.ora file?

I am trying to create a bash script to run an SQL query. The issue that I have is that the connection strings that I am using below is only giving me errors.
Example connection attempts with errors:
sqlplus -s username/password#hostname:Port:SID --> ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
sqlplus -s username/password#hostname:Port/SID ---> ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Example on my (local) XE database. Let's just check what TNSNAMES.ORA says (I obfuscated host name) so that you'd see what I used while connecting to the database. If you don't have TNSNAMES.ORA, then you'll have to find that info somehow (possibly by asking your DBA).
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = my_host)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
OK, let's try it now:
c:\Temp>sqlplus scott/tiger#my_host:1521/xe
SQL*Plus: Release 11.2.0.2.0 Production on Uto Svi 4 21:52:46 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
Using localhost's IP address (as I said, XE runs on my laptop):
c:\Temp>sqlplus scott/tiger#127.0.0.1:1521/xe
SQL*Plus: Release 11.2.0.2.0 Production on Uto Svi 4 21:53:07 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
Using localhost itself:
c:\Temp>sqlplus scott/tiger#localhost:1521/xe
SQL*Plus: Release 11.2.0.2.0 Production on Uto Svi 4 21:56:17 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

I am getting this error :ORA-12560: TNS:protocol adapter error in window 10 while coonecting to sql plus

I keep on getting this error . I have corrected ora.listner file as mentioned in other answer of similar problem in stack overflow and I was able to login too but problem start again when I open my window 10 again today.error
listner.ora
Result of lsnrctl status
open listner.ora file without editing and saved it and restart i am able to connect now. Every time i have to do this to connect
Most likely the Oracle service hasn't started. Open up powershell and check it with
get-service OracleService*
If it says it's stopped then you can do
get-service OracleService* | start-service
If it has started then your oracle_sid environment variable hasn't been set or your oracle_home isn't correct.
Unfortnately, I cannot see where you showed the actual sqlplus command, just a screen shot that picks up after sqlplus gets control. But I find the near 100% of the time I see this error, it is because sqlplus is started without specifying a connect descriptor. Doing so means you are asking for a local connection, so the listener, nor any other TNS component is not involved at all. Instead, sqlplus tries to make a local (in memory) connection to the running instance that is specified by the environment variable ORACLE_SID:
TNS Connection:
G:\scripts>sqlplus scott/tiger#edstest
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:46:01 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Tue Oct 27 2020 15:45:42 -05:00
Connected to:
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
SQL>
local connection, check ORACLE_SID first
G:\scripts>echo %ORACLE_SID%
edstest
G:\scripts>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:47:32 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Tue Oct 27 2020 15:46:01 -05:00
Connected to:
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production
SQL>
Local connection with ORACLE_SID not set, or improperly set:
G:\scripts>set ORACLE_SID=FUBAR
G:\scripts>echo %ORACLE_SID%
FUBAR
G:\scripts>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:48:57 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name: ^C
G:\scripts>set ORACLE_SID=
G:\scripts>echo %ORACLE_SID%
%ORACLE_SID%
G:\scripts>sqlplus scott/tiger
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 27 15:49:59 2020
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
Enter user-name:
And there's your error.

Oracle Database Connection issue with SSH Tunnel - Logon denied

We are not able to connect to Oracle DB using SSH Tunnel(set up in putty) from our system command prompt. It is failing with below error:
C:\Users\yadavvin>tnsping APPSP
TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 16-OCT-2019 11:54:54
Copyright (c) 1997, 2010, Oracle. All rights reserved.
sed parameter files:
C:\Oracle\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact **(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = appsp)))**
OK (130 msec)
C:\Users\yadavvin>
C:\Users\yadavvin>sqlplus arpadmin/password#appsp
SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 16 11:55:48 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
**ORA-01017: invalid username/password; logon denied**
Enter user-name:
C:\Users\yadavvin>
However, the same credentials are working with the same SSH Tunnel when connected using SQL DEVELOPER.
Would appreciate any pointers towards resolution of this issue.
Oracle DB Version: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Oracle Client Version: Release 11.2.0.1.0 Production
Adding the full qualified Database string in SQLPLUS and checking the connection:
C:\Users\yadavvin>sqlplus arpadmin/Welc0me2abcr#127.0.0.1:1521/AVSAPPSP
SQL*Plus: Release 11.2.0.1.0 Production on Wed Oct 16 14:49:50 2019
Copyright (c) 1982, 2010, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

TNS:Protocol Adapter Error

I am attempting to connect to an Oracle 11.2.0.2 64 bit database from a Win 7 and Win 8.1 machine with the Oracle 11.2.0.4 32 bit client. I can successfully ping the server and TNSPing the listener on both machines. But when I try to log into SQLPLus using system and my password I receive ORA-12560 TNS:Protocol Adapter Error. I can log into SQLPlus on the server. Any ideas? DB has been restarted as well as the listener. ORACLE_SID is set. I'm stuck...
If I'm following what you're seeing, it sounds like you just want to set the LOCAL enviroment variable on your Windows boxes to the TNS alias; then you don't have to supply that as you try to connect.
This is with the 12c instant client but the effect is the same with the 11g client. Specifying an alias as the connect strings works (the ORA-01017 is still coming from the DB):
c:\Program Files\instantclient_12_1>sqlplus -l x/y#abcd
SQL*Plus: Release 12.1.0.2.0 Production on Mon Feb 23 17:12:34 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
Connecting without the alias gets your ORA-12560:
c:\Program Files\instantclient_12_1>sqlplus -l x/y
SQL*Plus: Release 12.1.0.2.0 Production on Mon Feb 23 17:11:58 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-12560: TNS:protocol adapter error
But if I set LOCAL then I can connect as if I had specified the alias:
c:\Program Files\instantclient_12_1>set LOCAL=abcd
c:\Program Files\instantclient_12_1>sqlplus -l x/y
SQL*Plus: Release 12.1.0.2.0 Production on Mon Feb 23 17:14:23 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
You don't need to have ORACLE_SID set as that is only used for bequeath connections where the client and server are on the same box.

Resources