Unable to connect using instant client SQL*Plus - oracle

I am trying to connect to Oracle using SQL*Plus from Oracle instant client 12.2 but it keeps failing.
# export LD_LIBRARY_PATH=/root/oracle/instantclient_12_2
# ./sqlplus USERNAME/PASSWORD#remotehost.ancd.com:1881/TEST1.ancd.com
SQL*Plus: Release 12.2.0.1.0 Production on Fri Jan 19 19:04:03 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
I am not an Oracle expert but my understanding is I don't need a tnsnames.ora in Oracle client 12 for direct connection.
What I am going wrong?

Related

Error while connecting to schema using hostname in OCI cloud

I'm trying to import the full database to a pluggable database in Linux OS. I am getting the below error while connecting to the schema.
sqlplus system#OCIPROD
SQL*Plus: Release 12.1.0.2.0 Production on Sun Aug 28 10:25:21 2022
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password: ERROR: ORA-12514: TNS:listener does not currently know
of service requested in connect descripto
I tried pinging to TNS and listener services seem to be up.
Does anyone face this issue or can anyone help me to understand what could be the solution for this?

How to connect to Oracle using SQLPLUS | Oracle Instant Client | ORA-12545

Connecting successfully using SQL Developer but when i use sqlplus in Oracle Instant Client then i get following issues
Method 1:
[integrator#a-esb-app01 instantclient_19_8]$ ./sqlplus EGOINT#139.138.267.202:1521:EPROD
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Dec 22 18:14:36 2020
Version 19.8.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-12545: Connect failed because target host or object does not exist
Enter user-name: egoint
Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Method 2:
[integrator#a-esb-app01 instantclient_19_8]$ ./sqlplus EGOINT#139.138.267.202:1521/EPROD
SQL*Plus: Release 19.0.0.0.0 - Production on Tue Dec 22 18:18:13 2020
Version 19.8.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
Not Sure which of above is correct method and what is issue with connection string or any changes required on server side?
Note: I am able to connect another Oracle Server successfully. So no issue with InstantClient
Fixed using following:
./sqlplus egoint/egoint#(description=(address=(protocol=tcp)(host=139.138.267.202)(port=1521))(connect_data=(sid=EPROD)))

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.

Connect to Oracle as SYSDBA using OCI or SQL*Plus, from client machine

I'm using Instant-Client 12.1.0.2.0, connecting to a 12.1.0.1.0 (Linux) server, in Multi-Tenant configuration.
Using either:
SQL*Plus
OCILogon2
OCIServerAttach + OCISessionBegin(OCI_RDBMS credentials, OCI_DEFAULT mode)
I can connect (using EZCONNECT, no environment variables at all) from a client machine to a PDB on the server, using SYSTEM. E.g.
c:\>sqlplus system#'//host/pdb12c_1.domain.net'
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 20 11:14:10 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Last Successful login time: Tue Oct 20 2015 11:10:10 +02:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> quit
But as soon as I add as SYSDBA to the command line, it fails:
c:\>sqlplus system#'//host/pdb12c_1.domain.net' as SYSDBA
SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 20 11:14:22 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
ERROR:
ORA-01017: invalid username/password; logon denied
I've modified my OCI application to use OCI_SYSDBA as the mode to OCISessionBegin, and it fails the same way. I've tried SYSOPER with both SQL*Plus and my OCI client app, and it also fails the same way.
What am I missing? What kind of restriction are placed on connection that want to gain SYSDBA? Is this mode impossible from a client machine? Or is that because I connect to a PDB instead of the CDB?
I'd appreciate some insights. Thanks.
PS: yes, I double and triple checked I typed the password in correctly
c:>sqlplus system#'//host/pdb12c_1.domain.net' as SYSDBA
You are using SYSTEM user which is incorrect. You need to use SYS.
For example,
C:\Users\lkb>sqlplus sys#pdborcl as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Tue Oct 20 15:11:25 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>

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