Knowledge Base

Could not connect to the database, because the default is not set

ORA-12560: TNS:protocol adapter error

If you are on Windows, you can use following batch script to do some default checks:Ora12560.bat

Right click this link, choose save as and enter ora12560.bat as filename.
Next run the batch file in a dos box.

Following applies for Windows:
First of all, make sure you have set the correct ORACLE_SID:

C:\>sqlplus system/manager

SQL*Plus: Release 11.2.0.1.0 Production

ERROR:
ORA-12560: TNS:protocol adapter error

Enter user-name:
C:\>set ORACLE_SID=ORA112

C:\>sqlplus system/manager

SQL*Plus: Release 11.2.0.1.0 Production

Connected to:
Oracle Database

You can either set it before you startup sqlplus, or set it in the registry (HKEY_LOCAL_MACHINE\Software\Oracle\Key_ ;
create a new string with name ORACLE_SID and value the name of your database)

When you have created a new registry value, make sure to open a new dos box before starting sqlplus.

If this does not work, probably the OracleService for the database is not running.
Check if the service is running, if not, startup the service.
It might be that the service is setup to only startup the service and not the instance as well.
On Windows, use the oradim utility to control this behavior.
You will manually have to startup your database

C:\>sqlplus

SQL*Plus: Release 9.2.0.7.0 - Production 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Enter user-name: / as sysdba
ERROR:
ORA-12560: TNS:protocol adapter error

Restart the service

C:\>sqlplus

SQL*Plus: Release 9.2.0.7.0 - Production 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Enter user-name: / as sysdba
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  126951228 bytes
Fixed Size                   454460 bytes
Variable Size             109051904 bytes
Database Buffers           16777216 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.

If the service is running, you might be connected to the server using the Terminal Service Client / Windows Remote Desktop.

This is not supported by all versions of Oracle (before 9i).

One possible work around is to set the LOCAL environment variable in a dos box and try to connect again.
The difference between using LOCAL instead of ORACLE_SID is that LOCAL will try to connect through the listener, so it should run as well.

eg:

C:\>set LOCAL=ORA920

C:\>sqlplus

SQL*Plus: Release 9.2.0.7.0 - Production

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Enter user-name: / as sysdba
ERROR:
ORA-12541: TNS:no listener

C:\>set LOCAL=

C:\>set ORACLE_SID=ORA920

C:\>sqlplus

SQL*Plus: Release 9.2.0.7.0 - Production

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Enter user-name: / as sysdba

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.7.0 - Production

If the service is started and you are not using terminal services/remote desktop (using an unsupported version of Oracle) and you are relying on the default ORACLE_SID set for the Oracle Home Directory, than you’re probably using the incorrect %oracle_home%.

Use Oracle Locator express to change the Oracle Home, startup a new command prompt and try again.

If you are on Windows, you can use following batch script to do some default checks:Ora12560.bat
Oracle Gold Partner DbMotive is an Oracle Gold Partner