How to connect to two databases of Oracle using dblink - oracle

I am tring to use db link for that I have first change the name of both databases to sol1(remote) and sol3(local) then I create a db link
On sol3
CREATE DATABASE LINK SOL1.SWORLD
CONNECT TO TEST IDENTIFIED BY TEST USING SOL1;
LINK CREATED
ON SQL /> SELECT * FROM CAT#SOL1.WORLD
Message:
SQL COULD NOT RESOLVE THE SERVICE NAME
Then I dropped the database link and create a link from Oracle enterprise schema manager
I create a public link of fixed user. After login and password, I add the name in service tab as sol1
When I test the connection massage appears
Link is not active

I believe this is the source of your problem:
SQL COULD NOT RESOLVE THE SERVICE NAME
This indicates that SOL1 is not in tnsnames.ora, the entry is invalid or some network connectively issue is preventing Oracle from turning the service name into an address.

Make sure you have the entries in your tnsnames file.
NAME (DESCRIPTION (ADDRESS_LIST (ADDRESS = (PROTOCOL = TCP
)(HOST = host)(PORT = 1521))
)
(CONNECT_DATA (SERVICE_NAME = NAME)
)
)
You can now create your link in either direction.
create public database link "link name"
connect to schemaname
identified by " "
using 'servicename(from tnsnames entry)
;
Your link could be private also.

Related

How to connect Pentaho Data Integration with Oracle and TNS?

I want to make a connection to Oracle with Pentaho Data Integration, but I only find material with Pentaho Server on the internet.
In Data Integration I have two possibilities to connect to Oracle:
I am lost using the "Connection Type" of the TNS type and there is this option. In addition, there is "Network Alias".
How do I create an Oracle connection in Data Integration with these settings?
Pentaho
You must go to your tnsnames.ora file which is located on
%ORACLE_HOME%\network\admin\tnsnames.ora
If you are using the default TNS_ADMIN location, the file should be there. There will be an alias entry like this
ICXPRO=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = yourhost)(PORT = yourport))
)
(CONNECT_DATA =
(SERVICE_NAME = yourservicename)
)
)
Sometimes instead of SERVICE_NAME you might have SID. Once you got all these details, fill up the Pentaho details as follows:
Host Name --> your host
Database Name --> (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=yourhost)(PORT=yourport)))(CONNECT_DATA=(SERVICE_NAME=yourservicename)))
Port --> Your port
Tablespace Data and Tablespace Index --> leave the fields empty, just for the purpose of press TESTING
User --> your user
password --> your password
Sometimes , depending of the Pentaho version , the TNS string does not work for the field database name, then replace it with the Database SID.

ODBC Data Source with Oracle 11g

I am trying to connect to a Primavera P6 Database hosted on my network with driver Oracle in OraDb11g_home1. I currently have readonly access via the frontend, which I can successfully navigate records this way.
However, every attempt I have made to connect with a DSN has failed. I'm assuming that if I can connect to the frontend (even if readonly) that I should be able to connect via DSN with the same credentials?
The farthest I have gotten leaves me with an invalid username/password error. Here are the connection details:
in tnsnames.ora:
CHPPRIPA.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xamxilux002)(PORT = 1521))
)
(CONNECT_DATA =
(SID = CHPPRIPA)
)
)
I have similarly tried connecting using JDBC Driver (using a connection string) with the same username and password where
driver = "oracle.jdbc.driver.OracleDriver"
and
db_url = "jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ramxilux002)(PORT=1521)))(CONNECT_DATA=(SID=CHPPRIPA)))".
username = "csdba" # (Central Services Database Admin);Level 1 - P6 Client - View Only
I still get the same invalid username/password error.
Am I wrong in believing that the same credentials should get me the same access in both places? Anyone experience this problem?
The user interface known as P6 Professional or P6 Web uses different login credentials than what you need to get into the database. Only the DBA can give you those credentials.
Additionally, I would like to ask why you feel you need access to the database. This will impact how you connect to the database and which schema to use.
The SID you are showing is not typical of the "stock" installer/upgrader for Oracle databases running Primavera P6.
There are FIVE schemas in the Primavera P6 database. It is strongly recommended that you not attach to any except the extended schema for reporting.

Connect to an Oracle DB using ODBC

I am developing an application that needs to interract with a "lightly documented" Legacy Oracle Database. To Start that process I want to start creating a view into that Database using ODBC links into an MS Access database so I can figure out the DB structure but I can't figure out how to setup the ODBC connection to the Oracle DB.
I have been able to connect using the Host and Service Name to and view the DB using SQL Developer; but, I can't figure out how to setup ODBC. I am running Windows 7 and have installed Oracle 11g, Oracle Express Edition, the Instant Client and ODBC extensitons; but on the ODBC setup Oracle wants me to pick a TNS Service Name but there is none to pick and there is no place to specify the host. I tried to setup a TNS in tnsnames.ora; but I am not really sure I know the right location for that file.
I really thought this would be the easy part; but, it really hasn't been.
Navigate to the Control Panel > Administrative Tools > Data Sources (ODBC)
Select the System DSN tab and click 'Add'. Next scroll down the lists of drivers until you find Microsoft ODBC for Oracle.
Fill in the required information in the above form and click 'OK'. Now you can add the tables to 'Access' by clicking on the 'External Data' tab then clicking on 'More'. Choose 'ODBC Databases', then 'Import the source data...', next click on the 'Machine Data Source' tab.
The simplest option to generate the tnsnames.ora file is to let Oracle do it. If you launch the Oracle Net Configuration Assistant (Start | Oracle in Oracle Home Name | Configuration and Migration Tools | Net Configuration Assistant), you should be able to choose "Local Net Service Name configuration" which allows you to add (or modify) a TNS alias. That will walk you through gathering the information you'll need to connect.
If you are more comfortable dealing with the text files directly, you can directly edit the tnsnames.ora file in %Oracle Home%\network\ADMIN\tnsnames.ora using this as a template.
<TNS alias> =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <hostname or IP>)(PORT = <port>))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <database service name>)
)
)
In tnsnames.ora, try changing SERVICE_NAME to SID. That worked for me.
My Experience
1. TNSNAMES.ORA is as follows.
XE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 192.168.2.116)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SERVICE_NAME = XE)
)
)
Set Windows Environment Variables (ControlPanel --> System --> Detail..)
2-1. Add to PATH
c:\oraclexe\instantclient_11_2\ --- install directory of instantclient
2-2. Add New Environment Variable
TNS_ADMIN c:\oraclexe\instantclient_11_2\ --> install directory
NLS_LANG = JAPANESE_JAPAN.JA16SJISTILDE
Windows command prompt
cd c:\Windows\SysWow64 <--I use 32bit ODBC in 64bit Win7
odbcad32.exe
  Name : ICODBC <-- as you like
Service Name : XE
User Name: system
Press Connection Test Button

Can't create Database Link to remote DB in Oracle-DB

We have a CRM system in our company, which uses an Oracle 11g database. It is developed by a third party vendor.
We do not have access to the server which runs the CRM system. But nevertheless, we have working DBA login data available to us (SYS user). It consists of:
server IP: 172.1.2.3
port: 1521
SID: abc
user: sys
password: *
We can use this to access the DB with Oracle SQL Developer 3.1 (Connections >> Properties)
Now parts of the data must be copied out of the CRM-database into an other Oracle database, which resides on another server.
To my understanding, I'd need to create a database link in my target database. I tried something like this:
CREATE PUBLIC DATABASE LINK xxx CONNECT TO sys IDENTIFIED BY ***** USING 'MYTNSENTRY'
My tnsnames.ora is as follows:
MYTNSENTRY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.1.2.3)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = abc)
)
)
.... and my listener.ora look like this:
MYLISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.1.2.3)(PORT=1521))
))
SID_LIST_MYLISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=MYTNSENTRY)
(ORACLE_HOME=C:\somepath) # path to Oracle home of target DB
(PROGRAM=extproc)))
Is PROGRAM=extproc the right choice? There are a couple of other programs to pick. I couldn't even start the listener with lsnrctl because it could not "verify the user" or something. Ironically, the listener-setup and database link to a MS SQL server work smoothly.
Now despite lacking some vital information about the CRM DB system, one can still connect to the DB in SQL Developer. Shouldn't it also be possible to make a connection between two Oracle DBs? Please help me with the setup and the creation of the database link.
----- EDIT: --------
Alex Poole's hint helped me get it to work. I used
show parameters service_names;
to get the full service name. It has the form abc.def, with def being the domain. Thusly, I added the domain name to the TNS alias in tnsnames.ora:
MYTNSENTRY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.1.2.3)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = abc.def)
)
)
The connection can be tested with tnsping MYTNSENTRY on the command prompt of the target DB server. The tnsnames.ora is local. However, I deleted all changes to the "local" listener.ora, since the listener indeed resides on the CRM server.
The SQL command is mostly unchanged, but now the connection works:
CREATE PUBLIC DATABASE LINK xxx CONNECT TO some_user IDENTIFIED BY ***** USING 'MYTNSENTRY'
You've said the SID is abc, but in your tnsnames.ora you've got the SERVICE_NAME in the CONNECT_DATA section. They are not always the same thing - see this question, or this Ask Tom entry. You haven't actually said what error you're getting, but just changing that to SID = might make a difference.
The listener.ora, and indeed the listener, are on the server that hosts the CRM database, not on the one that hosts your 'target' database. As you can connect from SQL Developer that is apparently already configured. The tnsnames.ora does need to be local.
But if you do know the service_name for the CRM database you can skip that and use the EZCONNECT syntax to define everything in the link:
CREATE PUBLIC DATABASE LINK xxx
CONNECT TO non-sys IDENTIFIED BY *****
USING '//172.1.2.3:1521/service_name';
Check your SQL Developer configuration to see if that is already using the service name, rather than SID, and if not you'll need to discover it. If you had access to the CRM server you could use lsnrctl to find the service names that are registered, but as you don't seem to you will need to connect to the database and run show parameters service_names or select value from v$parameter where name = 'service_names';.
You need more privileges to create a public link than a private one, and public is potentially less secure as it exposes your CRM database to anyone on your target one. So I'd only make it public if really needed, and either way connect to a read-only account if you're able to create one.
Also note that if your target database has global_names set to true the database link name has to match the remote service name.
Not only should you NOT connect as SYS unless necessary, you CANNOT connect as SYS over a database link.

SSRS: Oracle TNS:listener error?

I have a SSRS report which is using Business Object Provider. The dll has a connection with Oracle server. Whenever i run the report i keep on getting this error message:
"Oracle.DataAccess.Client.OracleException ORA-12514: TNS:listener does not currently know of service requested in connect descriptor "
Anyone knows why?
It sounds like you installed the oracle client but have not yet set up your TNS listeners.
There should be a file called "tnsnames.ora" and inside that file you need to add a new listener. If it's a windows install there might also be a network configuration GUI.
A general tnsnames.ora entry would look like this if you choose to go that way:
DBAlias =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = YourDBServiceName))
)
Your tnsnames.ora file typically resides in the ORACLE_HOME/network/admin directory.
Technically speaking, you're not "creating a listener", rather, you're defining an alias for an Oracle client network connect string, which will refer to a listener somewhere.
Alternatively, you can specify an EZConnect string, if you don't want to/can't mess with tnsnames.ora entries:
"Data Source=//yourserver:1521/yourDB;User ID=theUser;Password=thePW"
You will need an entry in the sqlnet.ora file to the effect of:
NAMES.DIRECTORY_PATH = (TNSNAMES, EZCONNECT)

Resources