Why can't I connect via jdbc using SQLcl - oracle

I can connect to a remote database using SQLDeveloper.
I am trying to connect to the same database using sqlcl from the command line, but I am getting an error.
Here is the command that I am running:
/bin/sql username/pass#delphix-vdb-n-1.va2.b2c.nike.com:1521/vdbsl14
I have also tried:
/bin/sql username/pass#//delphix.......etc.
Here is the error I am receiving:
SQLcl: Release 4.2.0.16.131.1023 RC on Wed Jun 15 11:36:33 2016
Copyright (c) 1982, 2016, Oracle. All rights reserved.
USER = username
URL = jdbc:oracle:thin:#delphix-vdb-n-1.va2.b2c.nike.com:1521/vdbsl14
Error Message = Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
Username? (RETRYING) ('username/*********#delphix-vdb-n-1.va2.b2c.nike.com:1521/vdbsl14'?)
Also in SQLDeveloper, I just enter the following under "custom jdbc url" and it connects without any issue, so I was hoping I could connect via the command line using the same URL but so far, it is not working:
jdbc:oracle:thin:#delphix-vdb-n-1.va2.b2c.nike.com:1521:vdbsl4

It looks like your SID and service name are not the same. In SQL Developer you seem to be using the SID - at least in the custom JDBC URL you showed - as denoted by the colon in :vdbsl4.
Your SQLcl URL is using the service name, as denoted by the slash in /vdbsl14. Using the SID instead (i.e. changing the / to :) in that URL should work since it's using JDBC:
sqlcl username/pass#delphix-vdb-n-1.va2.b2c.nike.com:1521:vdbsl14
Alternatively (and preferably, in my opinion) find out what your service name actually is. If you have sufficient privileges on the database you can do show parameters service_names from SQL Devleoper, or if you have access to the server as DBA you can do lsnrctl services, or even look at the tnsnames.ora in case there is a TNS alias defined that shows the service name. (listener.ora isn't likely to help, but could give hints or if you're lucky show a default service name).
You can use that service name in a JDBC URL, as /service_name.
You can also use a TNS alias from SQLcl (or SQL*Plus). You may already have a tnsnames.ora available; if not you might be able to copy it from your server, or create your own. That can refer to the SID or the service name.
You can even pass a full TNS description to SQL*Plus (not sure about SQLcl) but that's a bit unpleasant. If you don't have/want a tnsnames.ora you can use 'easy connect' syntax, which is the same as you're using for SQLcl - but that has to be the service name, it doesn't allow SIDs.

Related

Point local TNS listener to remote database

I'm using neXtep to compare databases, and I'd like to use it for version control for an Oracle database. The connect string
REPORT_DEV2 = (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=dbs-nprd1-vm-002.mycompany.com)(PORT=1550))(CONNECT_DATA=(SERVICE_NAME=DEV.MYCOMPANY.COM)))
works with tnsping
TNS Ping Utility for 64-bit Windows: Version 18.0.0.0.0 - Production on 02-DEC-2019 21:22:55
Copyright (c) 1997, 2018, Oracle. All rights reserved.
Used parameter files:
C:\app\woodsman\product\18.0.0\dbhomeXE\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=dbs-nprd1-vm-002.mycompany.com)(PORT=1550))(CONNECT_DATA=(SERVICE_NAME=DEV.MYCOMPANY.COM)))
OK (20 msec)
The dialog
Is misleading. When I give it the service name as the database name, it says:
ORA-12505, TNS:listener does not currently know of a SID in the given connect descriptor.
I have no way of telling it to use a service name and not a SID. I'm hoping I can set up a TNS Listener entry in my local tnsnames.ora file that points to the service name that I want to use. Oh, and the neXtep program is on github, but is no longer being supported. Worse, I've tried but cannot figure out how to build it myself so that I can fix it.
I was able to find a SID to use. It seems that while I normally use a service name, somehow there's a local SID that gets built as part of the Oracle installation process. Nonetheless, for anyone who uses nexTep for Oracle, please make sure you have access to the SID name.
The Database name prompt in the nexTep dialog is really asking for a SID name. Bonus points to anyone willing to fix this one issue with nexTep so people can, out of the box, use an Oracle service name. Even better if they can change it to allow a straight up JDBC URL like every other Java based program.

Error while connecting to Oracle Server from Instant client through CMD prompt, but SQL Developer connects?

I am using Client provided laptop (windows XP professional 2002) and do not have administrative privileges (hence cannot st any required environment variables as well):
SQL Developer is provided and I am able to access the oracle server xaal5#:1521/ from SQL developer,
I need to use SQL LOADER to perform some heavy loading. I decided to download the instant client to see if I can save some time while my oracle client installation requests takes ages to go through approvals.
I went to the link: http://www.oracle.com/technetwork/topics/winsoft-085727.html
for Windows and downloaded the following Instant Client Downloads for Microsoft Windows (32-bit)
Version 10.2.0.4
Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
Download instantclient-basic-win32-10.2.0.4.zip (34,742,358 bytes)
*Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client
Download instantclient-sqlplus-win32-10.2.0.4.zip (725,418 bytes)
Extracted these two zip files into C:\instantclient-win32 folder, got the following files (Yes there is no SQL LOADER in it , but i decided to first set the oracle client up and then look for SQL LDR)
sqlplus.exe
oci.dll
ocijdbc10.dll
ociw32.dll
orannzsbb10.dll
oraocci10.dll
oraociei10.dll
Orasqlplusic10.dll
classes12.jar
ojdbc14.jar
glogin.sql
I Ran the following CMD prompt of windows machine:
sqlplus xaal5#:1521/SID
and got the following error :
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
I created a tnsnames.ora file with following entry:
PLMS = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = XXXXXX)(PORT = 1521))
(CONNECT_DATA =
(SID = sblcusdv)
))
and set up a USER VARIABLES to point to the path of tnsnames.ora file (in the Environment variables window) , as i cannot create a system variable.
$TNS_ADMIN=C:\instantclient-win32
I Ran the following CMD prompt again:
sqlplus xaal5#:1521/SID
and got the following error, again :
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
What am i doing wrong !! or is there another way to get SQL loader working on my system considering the constraints (long wait for approvals for oracle client installation).
When you use this format:
sqlplus xaal5#HOST:1521/SID
... you're using the 'easy connect' syntax, bypassing the tnsnames.ora and connecting to the service name SID - I assume you're actually using the SID from your TNS file, /sblcusdv. The SID and service name are not always the same thing, and the error indicates they are different in this environment.
To use your tnsnames.ora entry, use this syntax:
sqlplus xaal5#PLMS
That is, with the TNS alias you defined. If you don't want to use that file you need to know the service name. From the server you can use lsnrctl services to see which service names are registered, but you might not have access. If you have permissions you can do show parameters service_names from SQL*Plus (while connected via TNS), or you can query the performance views to get that information. But your account may not have access to that information either. In which case you'd need to ask your DBA. (I'm also assuming SQL Developer is connecting by SID, but it's possible it is using the service name, so you can just copy that).
sqlplus xaal5#//HOST:1521/SERVICE_NAME
You can't use SQL*Loader from the imstant client though, so you still have to wait for the full client to be installed. You might want to look at external tables as an alternative to SQL*Loader; then you could stick to instant client (or indeed SQL Developer). But you'd need to be able to get the data files into a DB-recognised directory on the server, which might haveits own issues.
You have to use the Description as stated.
sqlplus Username/Password#description
In your case:
sqlplus Username/Password#PLMS
This should be sufficient, no need to mention hostname or Port.
In case it doesn't work, check if your System variable PATH contain the oracle installation folder at first place. And when you have Oracle DB and Oracle Client installed on same machine, look if both TNSNAMES have the connection you looking for.

Unable to connect to oracle with different OS user accout

I have installed Oracle on Ubuntu with OS user oracle. When I try to connect to Oracle when logged on as different OS user (other than oracle), I get error:
SQL> connect user1/user1#orcl
ORA-12154: TNS:could not resolve the connect identifier specified
However, if I don't mention Oracle SID then I don't get any error:
SQL> connect user1/user1
Connected to:
Oracle Database
SQL>
I have declared ORACLE_HOME and SID in the user profile. But it did not work. Can someone please help me to understand the issue.
In a sense you don't really have a problem; you can connect locally using the ORACLE_HOME and ORACLE_SID environment variables, which is fine.
When you use the connect user1/user1#orcl version, the orcl is not your SID; as explained in the documentation it is an 'Oracle Net connect identifier'.
connect_identifier
An Oracle Net connect identifier. The exact syntax depends on the
Oracle Net configuration. For more information, refer to the Oracle
Net manual or contact your DBA. SQL*Plus does not prompt for a service
name, but uses your default database if you do not include a connect
identifier.
So you are connecting over a network connection, even though its to the same host, rather than internally using IPC. You don't even need to have ORACLE_SID set when you do that, because that is used for IPC and isn't part of the network connection.
Now, the connect identifier may well actually be the same string as your SID, but it doesn't have to be. Usually when you're using a single term like orcl you're using a 'net service name' which is defined in your tnsnames.ora file. (Depending on how the naming methods are configured in your sqlnet.ora, which determines how the connect identifier is resolved; but this is still the most common configuration I think).
The Oracle Net configuration can be configured using the netca configuration assistant, as the oracle user, though you can create a private tnsnames.ora to override that.
See the Oracle Net admin guide for more about how connectivity works and is configured, and the SQL*Plus user guide for a shorter version.
In order for your user1/user1#orcl connection to work you would need a tnsnames.ora entry looking something like:
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL=tcp)(HOST=my_host)(PORT=1521))
(CONNECT_DATA = (SERVICE_NAME = orcl)))
... where my_host is the DNS name or IP address of your Oracle server, and 1521 is the port the listener is configured to run on. (The listener has to be running for you to be able to connect this way, too). The SERVICE_NAME is not necessarily the same as your SID either, but depends on the database configuration; the lsnrctl status command will show what service names are available.
The ORA-12154 error is telling you that you either don't have a tnsnames.ora file at all, or that it doesn't contain an entry for the alias orcl.
As #a_horse_with_no_name points out, there are other forms of connect identifier, and you don't necessarily need a tnsnames.ora file for a network connection; the options are explained here. I've just focused on the one you were trying to use. You don't necessarily need to use any of them though since you are able to connect locally.

I can access my oracle database by command line, but cannot by navicat, ORA-12514 error

I use the command prompt to connect my Oracle database. All functions work, but when I try to use my Navicat to connect to the database, it shows the following error message:
ORA-12514:TNS:listener does not currently know of service requested in
connect descriptor.
My general settings for Navicat are:
host type:basic
ip address:127.0.0.1(also try my ip, but still have same problem)
port:1521
service name:orcl
By "all functions work", I assume you mean you are able to connect to the database and query.
Can you show us the connect that you use.
If you are using sqlplus in this fashion,
sqlplus userid/password#database1
it means your current client is pointing to the correct tnsnames.ora. May be navicat does not point to the correct tnsnames.ora file? The error indicates that you want to connect to, say database1, and Oracle is not able to map "database1" to the correct server, host and port number.
Have you gone through the connectiond details here?
http://www.navicat.com/en/products/navicat_oracle/oracle_detail_win.html
What is your operating system version and oracle version?

Cannot Connect with TOAD but Can with Other Tools/Apps

I am able to connect to an Oracle database using several tools, but am unable to connect using Toad for Oracle 8.5.3 (though before a login/logout to Windows I was able to).
I am not using TNSNAMES.ORA to connect. I have two Oracle homes:
C:\Oracle\product\10.2.0\client_1
(OraClient10g_home1) and
C:\Oracle\product\10.2.0\client_2
(ODACHome2)
where client 2 was installed after client 1.
I have tried Toad with each home, but I get "ORA-12154: TNS:could not resolve the connect identifier specified" when I supply the database name, user name, and password. I can connect using SQL*Plus using this same information, and I can connect via ADO.NET (ODP.NET). tnsping (client 2) to the server works, but tnsping (client 1) does not.
My PATH environment variable contains, in order:
C:\oracle\product\10.2.0\client_2\bin;C:\oracle\product\10.2.0\client_1\bin
and changing the order of PATH seems to have no effect. When I added the line
NAMES.DIRECTORY_PATH= (LDAP, TNSNAMES)
to sqlnet.ora of client 2, Toad still could not connect, but the error message appeared much more quickly.
I found the answer rather quickly after I posted, but I don't know if this is the best solution. I copied the ldap.ora file from client 1 to client 2. ldap.ora had lines like the following, which I have munged for security reasons:
DIRECTORY_SERVERS= (XXXXX:389:636,YYYYY:389:636)
DEFAULT_ADMIN_CONTEXT = ""
DIRECTORY_SERVER_TYPE = OID

Resources