Connection to an Oracle Database - oracle

I recently picked up a project where I need to build some SSIS packages that extract data from a remote Oracle database and load the data into a Sql Server database. The Oracle database is an old 32-bit Oracle 8i database. The Sql Server is 64-bit Sql Server 2008R2.
I can connect to the Oracle database from an old Win XP workstation no problem. When I try and connect from the Sql Server, I can't set a handshake.
I installed The Oracle Client 11g on the Sql Server box, copied the tnsnames file from the Install\Network\Admin\Sample to Install\Network\Admin and added the entry that worked on the XP workstation. When I try and create an ODBC connection using the Oracle ODBC Drviver, I get:
*Unable to connect Sql State=08004 ORA-12154: TNS:could not resolve the connect identifier specified.*1
My guess is that the driver can't find the TNS file. Is there anything else I have to configure? I checked the exception code via duckduckgo and I could not find anything.
Thanks in advance.

OK, I found it
I had to go into the Environment variables and define the ORACLE_HOME path. Once I did that, it connected.
This post got me on the right track.
Thanks

You have to use both of either 64 bit or 32 bit as your machine configuration. Make sure your server configuration is correct.

This might help someone stuck for "identifier not resolved issue":
If you have already checked the environment variables : PATH, ORACLE_HOME, TNS_ADMIN, please give a close look to tnsnames.ora entry for the given dsn. I had not given proper indentation and it was failing because of that!
Here is the entry with accurate indentation:
<dsn> =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <server>)(PORT = <port>))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <servicename>)
)
)

I had a similar problem where I was getting garbage in the TNS Services name list and testing the connection took forever. I found this was caused be a typo in the system environment variable setting for the TNS_ADMIN variable, where I had a space after the directory eg c:\oracle\instantclient_ (where _ is a space)
Removed and corrected the list garbage and connected straight away.
Hope this helps.

Of course you must check your TNSNAMES.ora at
C:\your_oracle_folder\app\oracle\product\11.2.0\server\network\ADMIN\TNSNAMES.ora
You should see at the top what is your system name. In my case Oracle 11g Express is "XE". Then configure your ODBC 32 or 64 bits depending on your platform:

Related

Missing listener.ora file

I'm attempting to make a connection to an Oracle Database with Microsoft Power BI Desktop.
Originally I was getting the following error message:
"The recommended provider ('Oracle.DataAccess.Client') is not
installed. You can continue with your current provider, however it has
been deprecated and may not work properly."
I've installed Oracle Database Access Components (ODAC), specifically "64-bit ODAC 12c Release 4 (12.1.0.2.4) for Windows x64" from this link. The message no longer appears. However, I now get a second error after attempting to connect to a database (which I can connect through Oracle's SQL Developer with no issues):
Unable to connect
We encountered an error while trying to connect.
Details: "Oracle: ORA-12541: TNS:no listener"
After install, there doesn't seem to be a "listener.ora" file located in %ORACLE_HOME%\network\admin\ folder at all. I do see "sqlnet.ora" and "tsnames.ora" but nothing else. Did I install the proper application or am I missing something? I tried doing a search of the file on the computer but nothing came up. Thanks.
If you are still having the problem see this Power BI Desktop Help page.
Manage your data Source - Oracle Power BI Desktop Help
Oracle Client --> [ Oracle Listener on Database Server --> Oracle Database Username ]
The Oracle Listener is normally located on the Oracle Database Server. Each Oracle Database running on the server will register Service Names with the Oracle Listener.
Oracle database initialization parameter local_listener
local_listener (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The local_listener is on the database server, the localhost port 1521.
The Oracle Client Networking Description Files are:
[Oracle Home Directory]\Network\Admin\sqlnet.ora
and
[Oracle Home Directory]\Network\Admin\tnsnames.ora
See the sqlnet.ora line [ NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT) ]
Default is TNSNAMES.
TNSNAMES reads the description from the tnsnames.ora file.
Add your tnsnames description to the tnsnames.ora file. Use the CONTOSO connection description below as a guide.
Check with the Database Administrator, for HOST, PORT and the database SERVICE_NAME parameters.
Use the Oracle tnsping command to check the connection description.
tnsping CONTOSO
CONTOSO = (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = oracleserver.contoso.com)(PORT = 1521))
 (CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = CONTOSO)
 )
)
Please remember that this is for the Power BI Desktop.
If you plan to move your Power BI Project to a Cloud Services or to a Local Power BI reporting server, check with your Server Administrator for connection information.

Unable to connect through ODP Managed driver

I have a windows forms app, in which I am trying to connect to Oracle 11g DB with OracleManaged driver, which ends with an exception "ORA-12154: TNS:could not resolve the connect identifier specified". However when I am trying to connect through ODP.NET 64bit dlls, it is connecting (for this I ensured building the app in x64). The sample code below. If I toggle to second statement, I am getting the error while opening the connection.
Oracle.DataAccess.Client.OracleConnection con = new Oracle.DataAccess.Client.OracleConnection();
//Oracle.ManagedDataAccess.Client.OracleConnection con = new Oracle.ManagedDataAccess.Client.OracleConnection();
con.ConnectionString = "Data Source=v3;User Id=xxx;Password=xxx;";
con.Open();
MessageBox.Show("Done");
con.Close();
Is there a setting I am missing? Even I tried with the configure.bat that came along with manaed ODP (64bit)
The reason is simple, your managed driver does not know where to find the TNSNAMES.ORA. Oracle says it depends on environment variables.
What we do here is to set TNS_ADMIN environment variable to the folder containing the TNSNAMES and everything works perfectly.
This is the best solution since it allows you not having multiple instances of TNSNAMES.ora on your station...
I got this worked by copying the tnsnames.ora file to bin folder. It seems like the managed driver couldn't find the right tnsname.ora file.

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.

TNS:name lookup failure

I have a stand-alone workstation at work that connects to an oracle database. It's been working fine for years and then all of sudden I get an error:
[INTERSOLV][ODBC Oracle driver][Oracle]ORA-12545: TNS:name lookup failure
When I ping the server I am trying to connect to from the command prompt, it replies back with the right IP address. If I do a TNSPING, that seems to be ok as well.
I have a separate PC that is on the computer network and it connects to the server just fine - it doesn't have that error above in bold.
There is another, different oracle database that I connect to on that stand-alone PC and it's still working fine. So, it's not like I lost the ability to connect to any or all Oracle databases - just something about this one.
I'm confused why it won't work and haven't had any luck trying to fix it. I'm not sure how to proceed.
Any help would be appreciated.
Try defining the environment variable TNS_ADMIN to point at the location where your TNSNAMES.ORA file resides.
EDIT:
Can you connect with SQL*Plus directly?
If it's installed, this should work (replace user and db with the userid and database to conenct to):
sqlplus user#db
Failing that, try connecting with EZCONNECT:
Modify sqlnet.ora file:
NAMES.DIRECTORY_PATH=(TNSNAMES,EZCONNECT)
Change your ODBC Connection in the Oracle ODBC Driver Configuration wizard to use the EZCONNECT string:
Replace the TNS Service Name with:
<db_host>:port/<db_name>
e.g.,
MYHOST:1521/MYDB
This points to the database MYDB on host MYHOST at port 1521 (the default port).
Try testing the connection. If that fails, try using the IP address instead of the hostname.
Given your TNSNAMES entry from your comments:
ESTRNP = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ESTRNP)(PORT = 1521))
)
(CONNECT_DATA = (SID = ESTRNP))
)
You might try changing the CONNECT_DATA line to:
(CONNECT_DATA = (SERVICE = ESTRNP))
It is possible that the SID of the database was changed. Is this entry the same as the entry on the machine that works?
do you have recently install any other oracle software?
It is possible that you have multiple tnsnames.ora files on different locations and the odbc driver finds the wrong one.
Inspect you path environment variable, whether the path to the right one is at the first place.

Unreliable Oracle connection (intermittent error "Connect failed because target host or object does not exist")

We recently changed physical DB's, new servers, new locations, same database schema and data and since the change over, whenever we try to connect directly to the DB in our own desktop type applications about half of the time we get this error:
SQL*Loader-704: Internal error: ulconnect: OCIServerAttach[0]
ORA-12545: Connect failed because target host or object does not exist
The rest of the time, it connects right away without any issues. Our applications that establish connections via JDBC don't seem to have any issues but we do when going through something that does a tnsnames.ora lookup (or that's my hunch at least). TNSPING works 100% but using an oracle executable like SQLLDDR fails at least 50% of the time. Here's an anonymized snppet of our TSNNAMES file and a TNSPING output:
DB_CONNECTION =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 1.2.3.4)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = MY.URL.COM)
)
)
And the TNSPING:
C:\>TNSPING DB_CONNECTION
TNS Ping Utility for 32-bit Windows: Version 9.2.0.1.0
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
C:\oracle\ora92\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 1.2.3.4)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = MY.URL.COM)))
OK (200 msec)
I have the SID of the DB, which is what the JDBC connections rely on but adding it to the tnsnames.ora doesn't improve the odds of making a connection. I don't know enough about how the tnsnames file is being used by Oracle to intelligently resolve this issue. What can I try?
Edit
The new DB's may be two load balanced databases which may be part of the problem.
We recently had a similar issue with our application. The application would sometimes connect to the Oracle RAC and sometimes it would complain with ORA-12545.
In short the issue was that the server had a real name while we were using virtual IP addresses in TNSNAMES.ORA. Once we added the mapping of the server name to IP address via system32\drivers\etc\hosts file everything started to work properly.
I have written a bit more in my blog
<shameless advert>http://dcarapic.blogspot.com/2009/04/intermittent-ora-12545-error.html</shameless advert>
Ah, gotta love the intermittent problems :)
(In the following I have had to replace the underscore character as I don't know the escape char for this wiki language)
Are you always using the same OS user to connect and to do the tnsping?
Check for environment variables TNS[underscore]ADMIN pointing to different tnsnames.ora locations. Do a scan of the client for duplicate tnsnames.ora; either in locations pointed to by $TNS[underscore]ADMIN or in different $ORACLE[underscore]HOMES (e.g. if you have 2 Oracle client installs).
Likewise check that you are using the same $ORACLE[underscore]HOME and $PATH environment variables for all connection attempts and tnsping. (E.g. always the same OS user or each user has the same values)
I see that the tnsping output reports version 9.2 so this is not likely, but in 11g the DB registers with the listener which can take a minute or so. (maybe also true with 10g). Attempts to connect prior to this will not find the target.
Another unlikely possibility - is a service with the same service name still advertised on the old host server? Remove it if at all possible.
After that I would start to look at the network itself. Is a ping of the server always successful and quick? If you're using the hostname rather than IP in the tnsnames.ora, does the hostname reliably resolve to the correct IP (nslookup). Is there a local firewall and if so is it behaving?
Regards
Karl
If you are using Oracle 10g, you may use an Easy Connect handler instead:
//servername/instancename
,
//1.2.3.4/my.url.com
in your case.
It's immune to lots of TNSNAMES issues.

Resources