{"id":21584,"date":"2019-12-07T03:21:57","date_gmt":"2019-12-07T03:21:57","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=21584"},"modified":"2024-12-07T14:55:07","modified_gmt":"2024-12-07T14:55:07","slug":"how-to-fix-ora-12514-tnslistener-does-not-currently-know-of-service-error","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-fix-ora-12514-tnslistener-does-not-currently-know-of-service-error\/","title":{"rendered":"Fix ORA-12514 TNS:listener Service Error"},"content":{"rendered":"<h1>Fix ORA-12514 TNS: listener Service Error<\/h1>\n<p>In this post, we will resolve and fix the following Oracle JDBC Thin Driver error. ORA-12514, TNS:listener does not currently know of service requested in connect descriptor.<\/p>\n<p>In this example, we will try to connect to the Oracle database using the Oracle JDBC Thin driver. We will connect to a pluggable database named orclpdb with the SCOTT schema.<\/p>\n<p>Setup schema steps can be found at:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.testingdocs.com\/questions\/how-to-connect-to-pluggable-database-pdb-using-sqlplus\/\" target=\"_blank\" rel=\"noopener\">Connect to Pluggable Database PDB using SQLPlus<\/a><\/li>\n<\/ul>\n<h2>Error Trace<\/h2>\n<p>java.sql.SQLRecoverableException: Listener refused the connection with the following error:<br \/>\nORA-12514, TNS: listener does not currently know of the service requested in the connect descriptor<br \/>\nat oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:854)<br \/>\nat oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)<\/p>\n<p>Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:<br \/>\nORA-12514, TNS:listener does not currently know of service requested in connect descriptor<\/p>\n<h2>Cause<\/h2>\n<p>A malformed service name usually causes this error in the database connection descriptor string used to connect in the JDBC program.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-21587 size-full\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ORA-12514-TNS-Listener-service.png\" alt=\"ORA-12514 TNS: listener Service Error\" width=\"1920\" height=\"1074\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ORA-12514-TNS-Listener-service.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ORA-12514-TNS-Listener-service-300x168.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ORA-12514-TNS-Listener-service-1024x573.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ORA-12514-TNS-Listener-service-768x430.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ORA-12514-TNS-Listener-service-1536x859.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<h2>Fix<\/h2>\n<p>Check if the connection descriptor string:<\/p>\n<p>For example, this is a malformed connection string according to the Oracle Database setup on the machine :<\/p>\n<p><em>&#8220;jdbc:oracle:thin:scott\/tiger@localhost:1521\/orcl&#8221;<\/em><\/p>\n<p>The connection descriptor string should be formed using the <strong><em>tnsnames.ora<\/em><\/strong> file from the database instance we are trying to establish the connection. The exact hostname, port, and service name are in the <strong><em>tnsnames.ora<\/em><\/strong> file.<\/p>\n<p>On Windows, the file can be found at the following path:<\/p>\n<p><em>%ORACLE_HOME%\\network\\admin<\/em><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21596\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/tnsnames-File-Oracle-TestingDocs.png\" alt=\"tnsnames File Oracle TestingDocs\" width=\"1920\" height=\"1072\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/tnsnames-File-Oracle-TestingDocs.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/tnsnames-File-Oracle-TestingDocs-300x168.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/tnsnames-File-Oracle-TestingDocs-1024x572.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/tnsnames-File-Oracle-TestingDocs-768x429.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/tnsnames-File-Oracle-TestingDocs-1536x858.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<ul>\n<li>1 -&gt; Hostname<\/li>\n<li>2 -&gt; Port<\/li>\n<li>3 -&gt; Service Name, here, in this case, the pluggable database.<\/li>\n<\/ul>\n<h2>JDBC Thin Service name Syntax<\/h2>\n<p>The correct format is:<\/p>\n<p><em>&#8220;jdbc:oracle:thin:&lt;username&gt;\/&lt;password&gt;@\/\/&lt;hostname&gt;:&lt;port&gt;\/&lt;servicename&gt;&#8221;;<\/em><\/p>\n<p>So the correct connection descriptor string is:<\/p>\n<p><em>&#8220;jdbc:oracle:thin:scott\/tiger@\/\/localhost:1521\/orclpdb.localdomain&#8221;<\/em><\/p>\n<h2><\/h2>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fix ORA-12514 TNS: listener Service Error : In this post, we will resolve and fix the following Oracle JDBC Thin Driver error. ORA-12514<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-21584","post","type-post","status-publish","format-standard","hentry","category-java","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=21584"}],"version-history":[{"count":22,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21584\/revisions"}],"predecessor-version":[{"id":26275,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/21584\/revisions\/26275"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=21584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=21584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=21584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}