Point local TNS listener to remote database - oracle

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.

Related

Why can't I connect via jdbc using SQLcl

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.

Communication between two databases (Oracle, VirtualBox)

Currently I am trying to understand how can two databases communicate to each other (for instance: get data from one to another).
Detailed description
I have two Oracle databases, one on Windows and latter on Oracle VirtualBox. On Windows DB I have one user (PAI) with single table called TESTME. On VirtualBox, only user (PAI_VB) was created. Now, I want to display the content of the TESTME table from SQL Developer from VB.
I have done
I want to display table TESTME using LINK statement:
CREATE DATABASE LINK LINK_TO_PAI
CONNECT TO PAI IDENTIFIED BY PAI
USING 'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=myIP)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=XE))';
Note: data from 'DESCRIPTION' section were taken from tnsname.ora file on Windows.
Having that, via following query I will manage to display table:
SELECT * FROM PAI.TESTME#LINK_TO_PAI;
Unfortunately, it does not work.
Error from console
ORA-12154: TNS:could not resolve the connect identifier specified
12154. 00000 - "TNS:could not resolve the connect identifier specified"
*Cause: A connection to a database or other service was requested using
a connect identifier, and the connect identifier specified could not
be resolved into a connect descriptor using one of the naming methods
configured. For example, if the type of connect identifier used was a
net service name then the net service name could not be found in a
naming method repository, or the repository could not be
located or reached.
*Action:
- If you are using local naming (TNSNAMES.ORA file):
- Make sure that "TNSNAMES" is listed as one of the values of the
NAMES.DIRECTORY_PATH parameter in the Oracle Net profile
Questions
Could you please propose solution to my problem (I know that in *Action section there is a hint but still I cannot solve it).
Maybe, you could introduce me another way to make communication between two databases possible.
EDIT
I managed to connect from my VB machine to one on Win10 via SQLDeveloper and SQLPlus. Unfortunately, using Oracle LINK I can not access data from database.
SOLVED !!
I managed to solve my issue. The problem laid in LINK. Since following part:
'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=myIP)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=XE))'
was inside tnsnames.ora file i should define my link as follows:
CREATE DATABASE LINK LINK_TO_PAI
CONNECT TO PAI IDENTIFIED BY PAI
USING 'xe';
After that minor change, I was able to freely us LINK in my example. Cheers :)
Here's what you need to have for a working database link:
Network connectivity between the two hosts.
Oracle Listener process running on the host you want to connect to.
Correct TNS entry while creating the link.
Correct username and password to connect to the remote database.
The TNS-12154 error you're getting means the database running on the virtual host can't get to XE's listener using the description you gave it.
Make sure you're using the correct IP address when trying to connect to your Windows host from your virtual machine.
Run tnsping from your virtual environment to see if it can get to the Windows host listener.
tnsping 'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=your_windows_host_ip_from_step_1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE))'
or just tnsping XE if you have the TNS entry stored as XE in tnsnames.ora file on your virtual machine.
See also: Oracle documentation — Testing Connections.
Once you get OK response from tnsping try connecting to XE with sqlplus (sqlplus PAI/PAI#XE) or via SQL Developer running on the virtual host. If you can connect that way your database link should also work with the same TNS entry.
This is a tricky part of oracle because there are a number of diverent ways to make a connection.
I suggest that you begin to make sure that you have a tnsnames.ora file both on windows and in your virtualbox environment. What os are you running in VirtualBox by the way?
In both tnsnames.ora files both databases should be named. Easiest to make them identical.
Then connect with sql*plus from windows to your database in VirtualBox and from VirtualBox to your database on Windows.
Just to make sure your network and tns config are OK.
If this works recreate your db-link with the servce alias from tnsnames after using. This should work.

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.

Where to get Oracle SERVICE_NAME?

I just installed Oracle database 10g free version for students on my Windows XP. I am confused how to know the SERVICE_NAME? Am running it at my localhost 127.0.0.1, with username SYSTEM. May I know where can I get to know the SERVICE_NAME?
It is normally XE for the free version. ORCL is another typical value.
Once logged in, it can be determined from
select sys_context('USERENV','SERVICE_NAME') from dual
If you need to know it so that you can log in, look for a file called TNSNAMES.ORA in
$ORACLE_HOME/rdbms/network/admin and the service name will probably be in the connection string.
Since its windows, you can go to control panel - administrative tools - services : (switch to classic mode in control panel if you do not see admin tools). Once there you will have a service by the name "Oracle service_". The is your service name.

Getting ORA-12560 with Oracle Express 10g

I started to receive this error while I`m using C# with Oracle 10g.
ORA-12560 and I really need to solve it as I`m running out of time on my grad project.
ORA-12560 is a configuration issue. This makes it difficult to diagnose remotely. I have answered a similar question on SO before. my advice is general enough that it should help you too. Find out more.
If it doesn't you'll need to post more details of your listener.ora, tnsnames.ora and perhaps your hosts files.
edit
"All the files are hosted here:"
Hmmmm. Both listener.ora andtnsnames.ora reference HOST = SIKAS-TOSH but server is not included in the hosts file.
edit 2
"the Oracle 10g Express Edition is
installed on my PC"
If your database is on your PC then the files on some web-server are irrelevant. It is the listener.ora andtnsnames.ora on your PC which matter. Those versions of the file need to reference HOST = localhost or else your hosts needs to include SIKAS-TOSH as an alias for 127.0.0.1.
Make sure your listener is running. If it is, try restarting it and re-registering your database with it (through sqlplus as sysdba, type the command alter system register;). Also, make sure that if you run a local firewall you have allowed the port 1521 for incoming traffic (or your custom port if you have changed this).
In Windows the listener is a service, prefixed with the oracle home name + TNSListener.
In Linux, set your oracle home environment and type:
lsnrctl stop
lsnrctl start
I have unintalled and re-installed the oracle 10g many times as well as the ODAC112011beta, last time I didn`t install the ODAC112011beta, instead, I used the Oracle.DataAccess.Client file found in the C:\oraclexe\app\oracle\product\10.2.0\server\BIN\Oracle.DataAccess.dll ... then I started the service from START->All Programs->Oracle Database 10g Express Edition->Start Database as administrator ... now I can connect to the Oracle through C# ... I hope I face no more problems

Resources