Ora 12514 как исправить

I had this issue and the fix was to make sure in tnsnames.ora the SERVICE_NAME is a valid service name in your database. To find out valid service names, you can use the following query in oracle:

select value from v$parameter where name='service_names'

Once I updated tnsnames.ora to:

TEST =
   (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = *<validhost>*)(PORT = *<validport>*))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = *<servicenamefromDB>*)
    )
)

then I ran:

sqlplus user@TEST

Success!
The listener is basically telling you that whatever service_name you are using isn’t a valid service according to the DB.

(*I was running sqlplus from Win7 client workstation to remote DB and blame the DBAs ;) *)

answered Apr 16, 2013 at 23:36

Brad Rippe's user avatar

Brad RippeBrad Rippe

3,3471 gold badge18 silver badges20 bronze badges

11

I know this is an old question, but still unanswered. It took me a day of research, but I found the simplest solution, at least in my case (Oracle 11.2 on Windows 2008 R2) and wanted to share.

The error, if looked at directly, indicates that the listener does not recognize the service name. But where does it keep service names? In %ORACLE_HOME%NETWORKADMINlistener.ora

The «SID_LIST» is just that, a list of SIDs and service names paired up in a format you can copy or lookup.

I added the problem Service Name, then in Windows «Services» control panel, I did a «Restart» on the Oracle listener service. Now all is well.


For example, your listener.ora file might initially look like:

# listener.ora Network Configuration File: C:apporacle_userproduct12.1.0dbhome_1networkadminlistener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:apporacle_userproduct12.1.0dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:C:apporacle_userproduct12.1.0dbhome_1binoraclr12.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

… And to make it recognize a service name of orcl, you might change it to:

# listener.ora Network Configuration File: C:apporacle_userproduct12.1.0dbhome_1networkadminlistener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:apporacle_userproduct12.1.0dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:C:apporacle_userproduct12.1.0dbhome_1binoraclr12.dll")
    )
    (SID_DESC = 
        (GLOBAL_DBNAME = orcl)
        (ORACLE_HOME = C:apporacle_userproduct12.1.0dbhome_1)
        (SID_NAME = orcl)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

Kevin's user avatar

Kevin

74.6k12 gold badges131 silver badges165 bronze badges

answered Mar 25, 2014 at 12:13

Joseph Argenio's user avatar

3

In my circumstances the error was due to the fact the listener did not have the db’s service registered. I solved this by registering the services. Example:

My descriptor in tnsnames.ora:

LOCALDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = LOCALDB)
    )
  )

So, I proceed to register the service in the listener.ora manually:

SID_LIST_LISTENER =
    (SID_DESC =
      (GLOBAL_DBNAME = LOCALDB)
      (ORACLE_HOME = C:Oracleproduct11.2.0dbhome_1)
      (SID_NAME = LOCALDB)
    )

Finally, restart the listener by command:

> lsnrctl stop
> lsnrctl start

Done!

answered May 31, 2017 at 23:39

manix's user avatar

manixmanix

14.4k11 gold badges68 silver badges106 bronze badges

1

I had this issue at Windows server 2008 R2 and Oracle 11g

go to Net Manager > Listener > select database services form the combox > «Global Database Name» must be same as «SID» and «Oracle Home Directory» must be correct.

If you don’t have any entry for database services, create one and set correct global database , sid and oracle home.

Mr_and_Mrs_D's user avatar

Mr_and_Mrs_D

31.8k37 gold badges178 silver badges356 bronze badges

answered Dec 21, 2013 at 14:27

Sepideh's user avatar

SepidehSepideh

1491 silver badge2 bronze badges

1

This really should be a comment to [Brad Rippe][1]’s answer, but alas, not enough rep. That answer got me 90% of the way there. In my case, the installation and configuration of the databases put entries in the tnsnames.ora file for the databases I was running. First, I was able to connect to the database by setting the environment variables (Windows):

set ORACLE_SID=mydatabase
set ORACLE_HOME=C:Oracleproduct11.2.0dbhome_1

and then connecting using

sqlplus / as sysdba

Next, running the command from Brad Rippe’s answer:

select value from v$parameter where name='service_names';

showed that the names didn’t match exactly. The entries as created using Oracle’s Database Configuration Assistant were originally:

MYDATABASE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = mylaptop.mydomain.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydatabase.mydomain.com)
    )
  ) 

The service name from the query was just mydatabase rather than mydatabase.mydomain.com. I edited the tnsnames.ora file to just the base name without the domain portion so they looked like this:

MYDATABASE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = mylaptop.mydomain.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydatabase)
    )
  ) 

I restarted the TNS Listener service (I often use lsnrctl stop and lsnrctl start from an administrator command window [or Windows Powershell] instead of the Services control panel, but both work.) After that, I was able to connect.
[1]: https://stackoverflow.com/users/979521/brad-rippe

answered Dec 19, 2016 at 14:38

Capricorn1's user avatar

Capricorn1Capricorn1

8199 silver badges15 bronze badges

1

Starting the OracleServiceXXX from the services.msc worked for me in Windows.

answered Jun 16, 2015 at 7:48

Ishildur Baggins's user avatar

1

For thoses Who are using spring-boot and jdbc for connection.
You have to be careful while writing jdbcUrl in application.properties

With SID in Database connection —
source.datasource.jdbcUrl = jdbc:oracle:thin:@[HOST][:PORT]:SID

With Service name in db connection
globe.datasource.jdbcUrl = jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE

This worked for me :)

answered Jun 16, 2020 at 8:18

surajmall's user avatar

surajmallsurajmall

1481 silver badge6 bronze badges

For Dbeaver users: try selecting «SID» instead of «Service name» in connection settings.

answered Aug 30, 2021 at 6:49

JanBrus's user avatar

JanBrusJanBrus

1,1489 silver badges13 bronze badges

1

I had the same problem. For me, just writing

sqlplus myusername/mypassword@localhost

did the trick, doing so makes it connect to the default service name, I guess.

Hosana Gomes's user avatar

answered Sep 9, 2014 at 4:01

Hossein's user avatar

HosseinHossein

23.9k34 gold badges119 silver badges222 bronze badges

2

This error can occur when an application makes a new connection for every database interaction or the connections are not closed properly. One of the free tools to monitor and confirm this is Oracle Sql developer (although this is not the only tool you can use to monitor DB sessions).

you can download the tool from oracle site Sql Developer

here is a screenshot of how to monitor you sessions. (if you see many sessions piling up for your application user during when you see the ORA-12514 error then it’s a good indication that you may have connection pool problem).

enter image description here

answered Apr 1, 2013 at 0:21

grepit's user avatar

grepitgrepit

20.8k6 gold badges101 silver badges81 bronze badges

Check to see the database is up. Log onto the server, set the ORACLE_SID environment variable to your database SID, and run SQL*Plus as a local connection.

answered May 29, 2012 at 0:50

DCookie's user avatar

DCookieDCookie

42.4k11 gold badges83 silver badges91 bronze badges

1

I resolved this issue in my linux enviroment updating the IP of my machine in /etc/hosts file.

You can verify your network IP (inet end.) with:

$ifconfig

See if your IP matches with /etc/hosts file:

$cat /etc/hosts

Edit your /etc/hosts file, if nedded:

$sudo gedit /etc/hosts

Bye.

answered Sep 3, 2014 at 15:27

Sergio Marcelo C Figueiredo's user avatar

2

what worked for me was really simple, I just needed to initiate the service manually in the «Windows Services» (services.msc in cmd trompt).
my service name is: OracleServiceXXXXX.

answered May 12, 2016 at 13:57

isabelle martz's user avatar

isabelle martzisabelle martz

1711 gold badge3 silver badges12 bronze badges

1

I had also faced the same problem and spent 3 days to dig it out.

This happens because of your wrong TNS service entry.

First check whether you are able to connect to standby database from primary database using sql > sqlplus sys@orastand as sysdba (orastand is a standby database).

If you are not able to connect then it is a problem with the service. Correct the entry of service name in TNS file at primary end.

Check standby database the same way. Make the changes here too if required.

Make sure the log_archive_dest_2 parameter has the correct service name.

Gryu's user avatar

Gryu

2,0522 gold badges16 silver badges29 bronze badges

answered Jun 26, 2014 at 6:41

user3778101's user avatar

For those that may be running Oracle in a VM (like me) I saw this issue because my VM was running out of memory, which seems to have prevented OracleDB from starting up/running correctly. Increasing my VM memory and restarting fixed the issue.

answered Apr 14, 2016 at 18:14

th3uiguy's user avatar

th3uiguyth3uiguy

1,8791 gold badge12 silver badges8 bronze badges

Lots of answers here, but here comes a working example with code that you can copy and paste and test immediately:

For me the error 12514 was solved after specifying the correct SERVICE_NAME.
You find that on the server in the file tnsnames.ora which comes with 3 predefined service names (one of them is «XE»).

  1. I installed the Oracle Express database OracleXE112 which already comes with some preinstalled demo tables.
  2. When you start the installer you are asked for a password. I entered «xxx» as password. (not used in production)
  3. My server runs on the machine 192.168.1.158
  4. On the server you must explicitely allow access for the process TNSLSNR.exe in the Windows Firewall. This process listens on port 1521.
  5. OPTION A: For C# (.NET2 or .NET4) you can download ODAC11, from which you have to add Oracle.DataAccess.dll to your project. Additionally this DLL depends on: OraOps11w.dll, oci.dll, oraociei11.dll (130MB!), msvcr80.dll.
    These DLLs must be in the same directory as the EXE or you must specify the DLL path in: HKEY_LOCAL_MACHINESOFTWAREOracleODP.NET4.112.4.0DllPath. On 64 bit machines write additionally to HKLMSOFTWAREWow6432NodeOracle...
  6. OPTION B: If you have downloaded ODAC12 you need Oracle.DataAccess.dll, OraOps12w.dll, oci.dll, oraociei12.dll (160MB!), oraons.dll, msvcr100.dll. The Registry path is HKEY_LOCAL_MACHINESOFTWAREOracleODP.NET4.121.2.0DllPath
  7. OPTION C: If you don’t want huge DLL’s of more than 100 MB you should download ODP.NET_Managed12.x.x.x.xxxxx.zip in which you find Oracle.ManagedDataAccess.dll which is only 4 MB and is a pure managed DLL which works in 32 bit and 64 bit processes as well and depends on no other DLL and does not require any registry entries.
  8. The following C# code works for me without any configuration on the server side (just the default installation):
using Oracle.DataAccess.Client;
or
using Oracle.ManagedDataAccess.Client;

....

string oradb = "Data Source=(DESCRIPTION="
    + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.158)(PORT=1521)))"
    + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));"
    + "User Id=SYSTEM;Password=xxx;";

using (OracleConnection conn = new OracleConnection(oradb)) 
{
    conn.Open();
    using (OracleCommand cmd = new OracleCommand())
    {
        cmd.Connection  = conn;
        cmd.CommandText = "select TABLESPACE_NAME from DBA_DATA_FILES";

        using (OracleDataReader dr = cmd.ExecuteReader())
        {
            while (dr.Read())
            {
                listBox.Items.Add(dr["TABLESPACE_NAME"]);
            }
        }
    }
}

If the SERVICE_NAME=XE is wrong you get error 12514. The SERVICE_NAME is optional. You can also leave it away.

answered Apr 20, 2017 at 21:19

Elmue's user avatar

ElmueElmue

7,4422 gold badges46 silver badges57 bronze badges

1

In my case the database had ran out of disk space. Which caused it to not respond. Once I cleared up that issue everything worked again.

answered Apr 20, 2014 at 2:12

Pete Brumm's user avatar

Pete BrummPete Brumm

1,65619 silver badges13 bronze badges

1

I got the same error because the remote SID specified was wrong:

 > sqlplus $DATASOURCE_USERNAME/$DATASOURCE_PASSWORD@$DB_SERVER_URL/$REMOTE_SID 

I queried the system database:

select * from global_name;

and found my remote SID («XE»).

Then I could connect without any problem.

answered Oct 13, 2017 at 10:55

Laura Liparulo's user avatar

In my case, round brackets around the SERVICE_NAME was missing in the tnsnames.ora file.

<DBNAME> =
  (DESCRIPTION =
    (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL=TCP)(HOST = nupark-cnvr-ora )(PORT=1521))
    )
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = <DBNAME> ***CLOSING ROUND BRACKET WAS MISSING HERE***
    )
  )

LISTENER_<DBNAME> =

  (ADDRESS = (PROTOCOL = TCP)(HOST = nupark-cnvr-ora)(PORT = 1521))

answered Mar 10, 2020 at 17:59

Mosab Sasi's user avatar

Mosab SasiMosab Sasi

1,1308 silver badges11 bronze badges

I had just to replace my connection string

from:

jdbc:oracle:thin:@localhost:1521:xe

To:

jdbc:oracle:thin:@localhost:1521:orcl

Steven's user avatar

Steven

1,9173 gold badges21 silver badges33 bronze badges

answered Oct 27, 2022 at 2:49

rahul Bhavar's user avatar

For me this was caused by using a dynamic ipadress using installation. I reinstalled Oracle using a static ipadress and then everything was fine

answered Dec 3, 2016 at 7:45

Steef's user avatar

SteefSteef

5615 silver badges20 bronze badges

Restarting the VM worked for me

answered Mar 20, 2019 at 3:35

wishman's user avatar

wishmanwishman

7744 gold badges14 silver badges31 bronze badges

My issue was resolved by replacing the’SID’ in URL with ‘service name’ and correct host.

answered Aug 23, 2019 at 13:47

Sir. Hedgehog's user avatar

Sir. HedgehogSir. Hedgehog

1,2503 gold badges17 silver badges39 bronze badges

tnslsnr is up but database is down.

For oracle novice it is not obvious that database may be down while connections are accepted.

I had to start up database manually like that

su - oracle
export ORACLE_SID=XE
sqlplus sys as sysdba

And then in sql console

startup

In my case i failed to startup but got another error message and found the source of a problem — i had to change host name and then database auto startup was functional again.

answered Nov 11, 2019 at 9:38

user3132194's user avatar

user3132194user3132194

2,32123 silver badges17 bronze badges

I have implemented below workaround to resolve this issue.

  1. I have set the ORACLE_HOME using command prompt
    (right click cmd.exe and Run as System administrator).

  2. Used below command

    set oracle_home="path to the oracle home"

  3. Go to All programs —> Oracle -ora home1 —> Configuration migration tools —> Net Manager —> Listener

  4. Select Database Services from dropdown.
    Both Global database name and SID are set to the same (ORCL in my case).
    Set Oracle Home Directory.

Oracle Net Manager window example from oracle documentation:
Oracle Net Manager example

  1. Click on File and save network configuration.

Gryu's user avatar

Gryu

2,0522 gold badges16 silver badges29 bronze badges

answered Nov 29, 2017 at 12:34

Raman B's user avatar

Raman BRaman B

3214 silver badges5 bronze badges

The problem was that my connection string url contained database name instead of SID.
Replacing database name with oracle database connection SID solved this problem.

To know your oracle SID’s you can browse tnsnames.ora file.

XE was the actual SID, so this is how my tomcat connection string looks like now:

    <Resource
       name="jdbc/my_db_conn"
       auth="Container"
       type="javax.sql.DataSource"
       driverClassName="oracle.jdbc.driver.OracleDriver"
       url="jdbc:oracle:thin:@//127.0.0.1:1521/XE"
       username="test_user"
       password="test" />

My server version was «Oracle 11.2 Express», but solution should work on other versions too.

answered Dec 5, 2019 at 12:07

Benas's user avatar

BenasBenas

2,0362 gold badges39 silver badges65 bronze badges

I had a case that I used DBMS where I had to fulfill a db connection form.

I put SID into the Database field and in the dropdown, next to the field, I had had ‘Service Name’ value instead of ‘SID’ value.
(normally I don’t use Oracle database so I’ve not been aware of the difference)

That was the reason I got the error message.

answered Jul 28, 2020 at 16:02

Bronek's user avatar

BronekBronek

10.6k2 gold badges45 silver badges46 bronze badges

The problem can be in the incorrect URL.

For example, I’m using Oracle database (inside VM) with Spring framework and having this issue.

I had in my application.properties file:

spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/orcl12c

But the db version was defferent:

spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/orclcdb

The correct URL can be found in the tnsnames.ora file (this file would be available where the Oracle server, so if you using VM, you should look for this file inside your host VM).
For example for Oracle in the VirtualBox the command to see this file is:

nano /u01/app/oracle/product/version/db_1/network/admin/tnsnames.ora

Dharman's user avatar

Dharman

30.3k22 gold badges84 silver badges132 bronze badges

answered Apr 17, 2021 at 21:59

x3hree's user avatar

x3hreex3hree

811 gold badge2 silver badges4 bronze badges

In my case for Linux environment, the oracle file at ORACLE_HOME/bin was highlighted in «Red» color with different permissions as below:
enter image description here

I changed the permissions of this file as below:

1) Stop Oracle -> sudo systemctl stop oracle.service
2) Change the permission of oracle file at ORACLE_HOME/bin directory as «sudo chmod 777 oracle«
3) Start Oracle -> sudo systemctl start oracle.service

Then after this change, I checked the status of listener using lsnrctl status.Here, I can see the db instances loaded successfully.

However, I can connect using sqldeveloper only, with sqlplus command line I’m getting ORA-12547: TNS Lost Contact error. So, this can a quick workaround to use sqldeveloper.

Note: Take a backup of oracle file before changing the permissions.

answered Aug 11, 2021 at 13:49

Rohit Gaikwad's user avatar

Rohit GaikwadRohit Gaikwad

3,6473 gold badges17 silver badges40 bronze badges

This is a tricky Oracle error, as it can have lots of possible causes.
It seems to mean that something in this chain of events is failing:

  • Look up the service name in tnsnames.ora
  • Connect to the host in the tnsnames entry
  • Reach the listener on that host
  • Tell the listener that you want to connect to the service specified in the tnsnames entry

Anything that throws that off can cause this error, from a missing bracket in tnsnames.ora, to a connecting to the wrong database host.

If tnsping works, that rules some things out, as it means that we can look up the entry in tnsnames, connect to the host, and contact the listener … so we know, for instance, that the host at least exists, and there is an Oracle listener running there; but the listener is saying the service name is not known. That still leaves a lot of possibilities like:

  • service name in tnsnames.ora is just wrong
  • database instance is not running and/or not registered with the listener
  • we’re connecting to the wrong Oracle host
  • we’re connecting to the wrong listener (wrong port) on the correct Oracle host
  • firewall/networking issue (apparently it’s possible that a firewall could allow tnsping packets through but block other client applications from connecting)

I’ve seen an ORA-12514 with tiny typos in tnsnames.ora … like incorrect indenting. But I suspect tnsping wouldn’t succeed if that is the issue.

When I encountered this most recently, it was due to the 3rd bullet-point above; we were connecting to an Oracle database host — just not the right host; we had to ensure that the hostname in the tnsnames entry was for the Oracle database server that was hosting this particular database service.

Connecting to the Oracle host and running lsnrctl status can help check that the service is known to this listener. Remember that lsnrctl by default checks the default listener name. You may need to check listener.ora to see if there are other names listeners in this database instance.

answered Apr 7 at 18:27

em_bo's user avatar

em_boem_bo

6246 silver badges13 bronze badges

null

ORA-12514 при подключении к экземпляру Oracle

Причин по которым может возникнуть ошибка ORA-12514 много, я расскажу об одной из возможных с предисторией.

У нашего заказчика развернут Oracle 11.2 на Windows Server.

При предоставлении заказчиком учётных данных для подключения нас насторожил обязательный формат логина SQLplus с явным указанием идентификатора соединения (connect_identifier)

sqlplus sys/pass@connect_identifier as sysdba

В процессе проведения работ нам потребовалось запустить базу данных в NOMOUNT через shutdown immediate,

C:Windowssystem32>sqlplus sys/pass@connect_identifier as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on ***

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Присоединен к:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate
База данных закрыта.
База данных размонтирована.
Экземпляр ORACLE завершен.
SQL> startup nomount
ORA-12514: TNS:прослушиватель в данный момент не имеет данных о службе, запрашиваемой в дескрипторе соединения

Коннекция без идентификатора соединения не удавалась(а именно она позволила бы поднять базу).

Решение

Проблема заключалась в некорректном значении системной переменной ORACLE_SID, значение которой не соответствовало названию экземпляра. В корректно настроенной системе переменная значение ORACLE_SID должно соответсвовать названию экземпляра отображенному в названии сервиса OracleService%sid_name%.

Изменение системной переменной решило описанную проблему.

Bonus Content: Download the Oracle SQL Cheat Sheet

Are you getting an “ORA-12514: TNS:listener does not currently know or service requested in connect descriptor” error? Learn what causes it and how to resolve it in this error.

If you try to connect to an Oracle database, you may receive this error:

ORA-12514: TNS:listener does not currently know or service requested in connect descriptor

This error means that a listener on the Oracle database has received a request to establish a connection. However, the connection descriptor mentions a service name that has not been registered with the listener, or has not been configured for the listener.

ORA-12514 Solution

There are a few steps to resolve this error.

  1. Check the service names on the database (if possible)
  2. Update TNSNAMES.ORA to include the service name

Step 1: Check the service names on the database

The first step to resolve the ORA-12514 is to see which service names the database knows about.

If you’re able to connect to your database, run the following query:

SELECT value
FROM v$parameter
WHERE name = 'service_names';
VALUE
XE

This will show all of the service names your database knows about.

You’ll need to add these into the TNSNAMES.ORA file, which I’ll show you how to do shortly.

What if you can’t connect to your database? This is a valid question, seeing as you’re getting this error when you try to connect to the database.

You could use a different connection string.

Or, you could connect to the server and run sqlplus locally.

Or, you could ask a coworker or a DBA to run this command for you.

This all depends on how your environment is set up.

While you’re here, if you want an easy-to-use list of the main features in Oracle SQL, get my SQL Cheat Sheet here:

Alternative: check which service names are known by the listener

Another way of seeing which service names are available to the listener is by running the lsnrctl command

lsnrctl services

This will show you the names of the services, which you can check against your connect descriptor. It’s an alternative way to getting the service names if you can’t connect to the database as mentioned in the previous step.

Step 2: Update your TNSNAMES.ORA file

After you have the name of the service, open your TNSNAMES.ORA file.

This file is located here:

%ORACLE_HOME%NETWORKADMIN

ORACLE_HOME is where your Oracle database is installed on the server, or on your own computer if you’re using Oracle Express.

For example, in my installed version of Oracle Express, my ORACLE_HOME is:

C:oraclexeapporacleproduct11.2.0server

So, my TNSNAMES is located here:

C:oraclexeapporacleproduct11.2.0servernetworkadmin

Your TNSNAMES.ORA file has one or more entries in it that represent your databases. They are in the following format:

<addressname> =
(DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(Host = <hostname>)(Port = <port>))
  )
(CONNECT_DATA =
  (SERVICE_NAME = <service_name>)
)
)

The addressname is what you use in the connection string, and service_name is what the service is known as on the database (from step 1)

Now, update the TNSNAMES.ORA by either adding a new entry or modifying an existing entry. You need to make sure that there is an entry that has a service_name value that is equal to the value you found in step 1.

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Ben-PC)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

Once you have done this, you should be able to connect to your database in the method you wanted to that caused this error.

sqlplus [email protected]

This should now work.

So, that’s how you resolve the ORA-12514 error.

You can read my guide to the Oracle errors here to find out how to resolve all of the Oracle errors.

Lastly, if you enjoy the information and career advice I’ve been providing, sign up to my newsletter below to stay up-to-date on my articles. You’ll also receive a fantastic bonus. Thanks!

While you’re here, if you want an easy-to-use list of the main features in Oracle SQL, get my SQL Cheat Sheet here:

Ok everything worked fine till yesterday now i am suddenly getting this error
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
nothing had been modified

XE =
  (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = jainam-2b1c493d)(PORT = 1521))
(CONNECT_DATA =
  (SERVER = DEDICATED)
  (SERVICE_NAME = XE)
)
)

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
        (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

  ORACLR_CONNECTION_DATA = 
      (DESCRIPTION = 
     (ADDRESS_LIST = 
     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) 
    ) 
     (CONNECT_DATA = 
   (SID = CLRExtProc) 
   (PRESENTATION = RO) 
 ) 
) 

I am totally stuck and have no idea what to do.
I tried help from here
http://dba-oracle.com/t_ora_12514_tns_listener_does_not_currently_know_service_requested.htm
but no use.
Thanks

EDIT:

here’s the output to lsnrctl service

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 3 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
      "ORACLE SERVER" established:0 refused:0 current:0 max:25 state:ready
        CLRExtProc
     (ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.pipeNTN_6B4_641B624E_B22.ORA))
  "ORACLE SERVER" established:0 refused:0 current:0 max:25 state:ready
     CLRExtProc
     (ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.pipeNTN_6B4_641B624E_282.ORA))
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
  "DEDICATED" established:0 refused:0
     LOCAL SERVER
Service "XEXDB" has 1 instance(s).
 Instance "xe", status READY, has 1 handler(s) for this service...
 Handler(s):
  "D000" established:0 refused:0 current:0 max:1022 state:ready
     DISPATCHER <machine: JAINAM-2B1C493D, pid: 3708>
     (ADDRESS=(PROTOCOL=tcp)(HOST=jainam-2b1c493d)(PORT=2763))
Service "xe" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
Handler(s):
  "DEDICATED" established:0 refused:0 state:ready
     LOCAL SERVER
The command completed successfully

ORA-12514 means that the listener cannot find any matched service with yours, so it cannot establish the connection with the database for you. As a result, it responds ORA-12514 to alert the failed connection.

As a DBA, I have seen several kinds of ORA-12514 in different scenarios and solved them by different means. Here I divide scenarios that could throw ORA-12514 into several error patterns as below:

  1. Common Situations
  2. Restarting a Database
  3. Switching over to Standby
  4. Using a Database Link

Only one thing that can be sure in ORA-12514 is that the target listener is up and running. That is to say, the listener is reachable.

For unknown requested SID, the listener throws ORA-12505: TNS:listener does not currently know of SID given in connect. It may have different error patterns from this post.

ORA-12514 in Common Situations

Let’s see how we get ORA-12514. First of all, we have to make sure the listener on the database server is reachable by using tnsping.

C:Usersed>tnsping ora11g

TNS Ping Utility for 64-bit Windows: Version 12.1.0.1.0 - Production on 22-JUL-2014 19:24:04

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
C:oracleappclientedproduct12.1.0client_1networkadminsqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL)))
OK (60 msec)

OK, the remote listener is up and reachable. Please note that, the message of successful tnsping did not indicate that the service name is existing on the remote listener.

Next, we test the connection to the database by sqlplus (SQL*Plus).

C:Usersed>sqlplus hr/hr@ora11g
...
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor

Enter user-name:

Cause

When the connection came, the listener found no matched service name registered with it. Consequently, the listener had no idea which database should be used to service the connection. Here are some possible causes of ORA-12514:

1. No instance

The database was not available or say idle, no any dynamic services registered with the listener. That’s why we saw ORA-12514.

2. Mismatched service name

The service name of the connect descriptor in tnsnames.ora did not match the service name in the listener. That is to say, the listener does not currently know of service requested in connect descriptor.

3. Not registered

If the database instance is up and running, the service name may not registered with the listener at specific port as you thought. By default, the service port of listener is 1521. But sometimes, it could switch to another port, say 1522.

Please note that, ORA-12514 is an error threw by the listener specifically for the client side. The database is no way to know such problem.

Solutions

The solutions to ORA-12514 are to make sure the following things:

1. The database is available

If there’s no instance, then no service name will register with the listener. You should startup the instance, then LREG will automatically register the service in 60 seconds.

If you are sure that the database is up and running and still got ORA-12514, things may be complicated. Let’s keep looking for other solutions.

2. The service names are matched

The service name in the connect descriptor of client’s tnsnames.ora shall match the service registered in the listener. Sometimes, it’s just a typo problem.

In short, the service names in the following 3 parties should be matched with each other in order to solve ORA-12514.

Service Names Shall Match for Solving ORA-12514

Service Names Shall Match for Solving ORA-12514

  • Connect descriptor.
  • The listener.
  • The database.

We talk about them respectively below.

Connect Descriptor

Let’s see an example of connect identifier. In which, the body is a connect descriptor.

[oracle@test ~]$ vi $ORACLE_HOME/network/admin/tnsnames.ora
...
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCL)
    )
  )

The question is, where is tnsnames.ora?

The Listener

The connect descriptor is easily checked, but how do we check the service names of the listener? See the following command:

[oracle@test ~]$ lsnrctl status
...
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status READY, has 1 handler(s) for this service...

For a specific listener name, you should do this:

[oracle@test ~]$ lsnrctl status <listener_name>

The Database

If there’s no matched service name in the listener, we should check the service names of the instance by OS authentication. No credentials are needed.

[oracle@test ~]$ sqlplus / as sysdba
...
SQL> show parameter service_names

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      ORCL

In case that you have no way to query the database, you can make a guess. Usually but not always, the service name is the same as the database unique name (DB_UNIQUE_NAME). The database unique name is the same as the instance name ($ORACLE_SID) for a single-instance database.

If both service names in the client and database are matched, but the listener showed a different service name or «The listener supports no services». The database may register a different listener, let’s keep reading this post.

3. The host and port are both right

Sometime, we may go for the wrong destination of the listener, either host or port was incorrect. As a result, we saw ORA-12514 because there’s no matched service name with that listener. We should check the host and port in the connect descriptor of the TNS name.

Chances are, the correct hostname may be resolved as the wrong IP address by DNS. Consequently, connections took us to the wrong database server. This could happen when we switched from an old machine to a new database server. So we should focus on name resolution problem first.

For those ORA-12514 caused by name resolution, we can use the IP address instead of hostname to connect the database for clients to work around it. Additionally, DBA should also check both values of HOST and PORT in listener.ora.

During the troubleshooting on the name resolution, you might see TNS-12545: Connect failed because target host or object does not exist temporarily.

4. Instance registers it services with the right listener

The instance may register with the another listener which services whatever port other than 1521. Consequently, no service name is supported by that listener.

That’s why we always see ORA-12514 only in clients or TNS-12514 in the listener’s log, the database instance will never know such problem.

Now we have a question: What listener is the instance using? If the database is using a different listener other than the default one, we can check a parameter named LOCAL_LISTENER for sure:

SQL> show parameter local_listener

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      (ADDRESS=(PROTOCOL=TCP)(HOST=o
                                                 racle-11g-server)(PORT=1522))

If the default listener at port 1521 in the same machine is used, the value could be empty. Otherwise, we will see the listener description like the above.

In a very rare case, the database uses a remote listener to register its service names. This is what Class of Secure Transports (COST) fights against.

For more troubleshooting beside ORA-12514, you may refer to Oracle 18c Net Services Administrator’s Guide: 15 Testing Connections.

ORA-12514 When Restart a Database

It’s pretty easy to explain why you got ORA-12514 when you restart a database. Please compare the following two cases.

Connect to the database through listener

[oracle@test ~]$ sqlplus /nolog
...
SQL> conn sys@orcl as sysdba
Enter password:
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

We saw ORA-12514 after we tried to startup the stopped database. Here is the reason: When you shutdown the instance, you lost the connection from the database and the service was unregistered from the listener, no more service information of the database on the listener. Therefore, ORA-12514 notified that you can’t do any further to this database in this way.

To solve ORA-12514 thoroughly, you should add a static service registration to the listener for your database. Otherwise, you have to connect to the database by OS authentication.

Let’s see how to avoid ORA-12514 if you are going to do critical jobs like shutdown or startup database through OS authentication.

Connect to the database through OS authentication

You don’t have to provide the password through OS authentication.

[oracle@test ~]$ sqlplus /nolog
...
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 1553305600 bytes
Fixed Size                  2253544 bytes
Variable Size             956304664 bytes
Database Buffers          587202560 bytes
Redo Buffers                7544832 bytes
Database mounted.
Database opened.

Can you tell the difference? By this method, you can never lose your connection during down time no matter the listener is up or not. No ORA-12514 interrupts you.

By the way, I talked about how to connecting an idle, NOMOUNT or RESTRICT database from remote clients in another post. It may help you to clarify some concepts about ORA-12514.

ORA-12514 When Switchover to Standby

DGMGRL> switchover to standby;
Performing switchover NOW, please wait...
Operation requires a connection to instance "primary" on database "standby"
Connecting to instance "primary"...
Connected.
New primary database "standby" is opening...
Operation requires startup of instance "primary" on database "primary"
Starting instance "primary"...
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Failed.
Warning: You are no longer connected to ORACLE.

This kind of error pattern of ORA-12514 is the most confusing, because you might have no idea what’s going on according to the last message «Failed» in console. This is what’s going on:

  1. The former standby is up and now playing the primary role.
  2. The former primary is down and going to play the standby role, but the data guard broker is unable to mount the instance due to the lost contact. As a result, we saw ORA-12514 in DGMGRL.

That is to say, the switchover is incomplete, but it does not mean a failure. This is because the former primary database is down and the broker lost the contact that caused ORA-12514.

Here are the actions that you have to take in order to complete the switchover. Please start up and mount the former «primary» database manually. After that, the data guard will automatically synchronize the data so as to complete the switchover.

The preventive action to ORA-12514 in an incomplete switchover is to add a very special static service in listener.ora for data guard broker to use.

ORA-12514 When Using a Database Link

A database link is just like a client which is trying to connect the remote database.

SQL> conn hr/hr
Connected.
SQL> select first_name from employees@ora11g_hr;
select first_name from employees@ora11g_hr
                                 *
ERROR at line 1:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

If the database link has been reliable for a long time, you should check the availability of the remote database. The causes that we have talked about in the section of ORA-12514 in Common Situations are still sustained. They may be:

  • The remote database is down. This is the most common cause of ORA-12514.
  • The connect descriptor in the local tnsnames.ora has been changed.
  • The service name of the remote database has been changed.
  • Another listener is used for servicing the remote database.

Usually, this type of ORA-12514 does not complain about the database link, except that you defined the database link with its own connect descriptor.

For example, we can create a database link with a full connect descriptor like this:

SQL> create database link ora11g_hr connect to hr identified by hr using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-11g-server)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = ORCL)))';

Database link created.

As you can see, we did not use a connect identifier, instead, we use a full connect descriptor. Therefore, if there’s anything wrong with the connect descriptor, we have to drop the database link then create a new one for solving ORA-12514.

Понравилась статья? Поделить с друзьями:
  • Как исправить 18 летие девушке
  • Как на айпаде найти ios
  • Как составить план рассказа левша
  • Как найти ботинок на картинке
  • Как найти статистику в вк через комп