Home » Infrastructure » Windows » ERROR:ORA-12154: TNS:could not resolve service name
ERROR:ORA-12154: TNS:could not resolve service name [message #212097] Wed, 03 January 2007 15:52 Go to next message
dandowney
Messages: 2
Registered: January 2007
Location: Atlanta
Junior Member
I am getting this error only when I run the Dos SQL Command line.
tnsping xe works just fine.

Output from tnsping:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = dell670)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = XE)))
OK (60 msec)

I can log into the database via enterprise manager and SQL WORKSHEET.

However, I can't connect via the SQL Dos Command line or my DLL.

Any Ideas?

Database is Oracle 10G
Server is Windows 2003

Here is my sqlnet.ora File:
# SQLNET.ORA Network Configuration File: C:\oracle9\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)

Here is my tnsnames.ora File:
# TNSNAMES.ORA Network Configuration File: C:\oracle9\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

XE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dell670)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = XE)
)
)


Thanks

Dan

[Updated on: Wed, 03 January 2007 15:58]

Report message to a moderator

Re: ERROR:ORA-12154: TNS:could not resolve service name [message #212144 is a reply to message #212097] Thu, 04 January 2007 00:31 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
excerpt
tnsping xe
Database is Oracle 10G
# SQLNET.ORA Network Configuration File: C:\oracle9\network\admin\sqlnet.ora
# TNSNAMES.ORA Network Configuration File: C:\oracle9\network\admin\tnsnames.ora

OK, XE is 10g, but - SQLNET.ORA and TNSNAMES.ORA either aren't the ones that should be used, you have installed more than one Oracle product, or you installed Oracle XE into an "oracle9" home.

Now, what happens when you set an environment variable to (for example)

C:\> SET tns_admin = c:\oracleXE\network\admin
C:\> SQLPLUS un/pw@xe

If it works, perhaps you could consider to merge ALL TNSNAMES.ORA files (located in all %oracle_home%\network\admin directories) into one file (you'd have to maintain this file only - adding new aliases would be done in this file) and point TNS_ADMIN variable to this, newly created file.

Doing so, SQL*Plus would know where to search for a database alias and you should be able to connect without any problem.
Re: ERROR:ORA-12154: TNS:could not resolve service name [message #212262 is a reply to message #212097] Thu, 04 January 2007 07:35 Go to previous message
dandowney
Messages: 2
Registered: January 2007
Location: Atlanta
Junior Member
Thanks Littlefoot !

You are correct about the tns_admin environment variable.

We had a server reboot and somehow my environment variable disappeared. So I went to Windows Control Panel, System, Advanced tab, Environment Variables at the bottom.
Click NEW and added an entry


Variable name=tns_admin
Variable value=C:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN

Just to clarify something, I have Oracle 9 Client installed for the tools but I am running an Oracle 10G database on the Windows server.

I hope this message my help somebody else who is running a DLL in a windows environment.

Previous Topic: Oracle XE 10g and odbc
Next Topic: ODBC Trace Log File Location Problem
Goto Forum:
  


Current Time: Fri Mar 29 07:21:47 CDT 2024