java.sql.SQLException: ORA-12154

We are getting java.sql.SQLException: ORA-12154:  TNS:could not resolve
service exception. It comes allof a sudden. It was working fine. But the issue got resolved once we recycle our Sunone Application server.

Any idea ..Is it something to do with momentary network issue, after which SunApplication server not able to connect to
database. At the time when we got this exception, we tried connnectig to database using sqlplus, it worked fine.

Oracle Troubleshooting
--------------------------------------------------------------------------------
ORA-12154: TNS:could not resolve service name
--------------------------------------------------------------------------------
Symptom:
When trying to connect to Oracle the following error is generated:

ORA-12154: TNS:could not resolve service name

Cause:
This error indicates that the service (or TNS alias) specified when trying to connect does not exist.

TNS aliases or service names are defined locally to each workstation. Thus different workstations could have a completely different alias to refer to the same database.

Remedy:
Check what aliases are defined on the workstation, either use one that is defined or add an appropriate one.

The following methods can be used to view the TNS names:

Look in the file ORANT\ Network\ Admin\ Tnsnames.ora (for versions of Oracle prior to 8.1) or Oracle\
Ora81\ Network\ Admin\ Tnsnames.ora (for versions of Oracle from 8.1 onwards). In this file each defined
name will normally have.world appended to it.

For Oracle 8, run Oracle Net8 Easy Config. This will list the available service names.

For Oracle 7, run SQL Net Easy Configuration. This provides the option to list the available service names.

For Oracle 8.1 onwards: Try specifying the full service name, i.e. as it appears in the tnsnames file.

If a connection alias is not being explicitly provided then try to identify what alias Oracle thinks you are
using. This will typically be contained in the sqlnet.log file that the Oracle client will produce.
Possible places where Oracle could be getting this (default) alias from:
The environment variableLOCAL

Chaz S

1.what version of oracle?
-------------------------------------------------------
You stated:
java.sql.SQLException: ORA-12154: TNS:could not resolve service name
------------------------------------------------------------------
Most probable case:
This may happen when a Java client requests a database connection but the database server has not started or
not listening.

Solution1. Make sure the service name in the host string is correct. e.g.

jdbc:oracle:oci8:@kesdee.world

Solution2. Start the Oracle Server

Solution3. Start the Listener. Under MS-DOS: 
lsnrctl.exe
start

Soution4. The tnsname specified in jdbc url is incorrect, check if the names match in ORACLE_HOME/network/admin/tnsnames.ora

Your problem must be solved by now:if not go down
further!!!!
--------------------------------------------------------------------
If not solved yet:RUN THE FOLLOWING CHECKS:

1>You mustve missed some vital info in SQLNET.ORA:
for egs:
NAMES.DEFAULT_DOMAIN entry missed Due to which you cannot start the application and the The JRE runs into Exception Errors!

2>Verify that a TNSNAMES.ORA file exists and is in the proper directory and is accessible.
- Check that the net service name used as the connect identifier exists in the TNSNAMES.ORA file.
- Make sure there are no syntax errors anywhere in the TNSNAMES.ORA file. Look for unmatched parentheses or
stray characters. Errors in a TNSNAMES.ORA file may make it unusable.

3>Verify that the host or database name is correct and that it is listed in the TNSNAMES.ORA file.This file
keeps a list of available databases and related information required to connect to them.

4>If you are using directory naming:
- Verify that &quo;LDAP&quo; is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the
Oracle Net profile (SQLNET.ORA)
-Verify that the LDAP directory server is up and that it is accessible.
-Verify that the net service name or database name used as the connect identifier is configured in the directory.
- Verify that the default context being used is correct by specifying a fully qualified net service
name or a full LDAP DN as the connect identifier - If you are using easy connect naming:
- Verify that &quo;EZCONNECT&quo; is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the
Oracle Net profile (SQLNET.ORA).
- Make sure the host, port and service name specified are correct.
- Try enclosing the connect identifier in quote marks.
---------------------------------------------------------------------
Channesh

Have a Oracle Question
Do you have an Oracle Question?

Oracle Books
Oracle Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.