Trying to connect Excel 2013 with Oracle - ORA-12154 - oracle

I am trying to connect into Oracle through Power Query > From Database > From Oracle Database and then I type BI_TST, which is within my TNSNAMES (located in: C:\oracle\product\10.2.0\client_2\network\ADMIN), and has the connection below inside:
BI_TST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = srv-oracle3.mycompany.com.br)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bitst)
)
)
Also i have the variable path configured as TNS_ADMIN=C:\oracle\product\10.2.0\client_2\network\ADMIN.
When I use SQL Developer to connect, not using TNS put setting all the information manually, it works!
When I try to connect using TNS within Excel I get the error:
Message=ORA-12154: TNS:não foi possível resolver o identificador de conexão especificado
ErrorCode=-2146232008
Wich means in English: "could not resolve the connect identifier"
Could anyone please help me in this issue?
Thanks in advance!

Honestly, I've had my fill of tnsnames. I understand the idea behind it and can appreciate that, but I spend more time figuring out why it's not working than I do saving the extra keystrokes.
In my opinon, just bypass TNSnames use Oracle's ezconnect:
srv-oracle3.mycompany.com.br:1521/bitst
In place of:
BI_TST
This should work for ODBC as well. If you can't direct connect through PowerQuery's Oracle driver, try going through ODBC. While it's an additional layer you probably don't want, I doubt you'll notice a performance difference, and it may abstract the difficulties you normally have to deal with.

To clarify Hambone's response, to connect Excel to Oracle via Oracle client driver without using TNS Names:
Go to Control Panel > Administrative Tools > ODBC Data Sources
Go to File DSN tab
Choose Oracle driver (e.g. Oracle11gr1)
Provide a name for the new data source (any name)
When prompted for Service Name, enter host:port/servicename e.g. db123:1521/service123
Hope this works for everyone.

Related

Listener refused the connection [duplicate]

I have installed Oracle 11g Express Edition Release 2 in my windows 7 64 bit OS and tried to execute JDBC program, then I got the following error:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.jlcindia.jdbc.JDBCUtil.geOracleConnection(JDBCUtil.java:28)
at Lab3O.main(Lab3O.java:15)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:385)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
... 8 more
I fixed this issue by correcting my jdbc string.
For example, the correct jdbc string should be...
jdbc:oracle:thin:#myserver:1521/XE
But the jdbs string I was using is ...
jdbc:oracle:thin:#myserver:1521:XE
(Note: between 1521 and XE should be a /)
This bad jdbc string give me a ORA-12505 error too.
There are a few things that can cause this problem, but before you get started with JDBC, you need to be sure that you can connect to the database using SQL*Plus. If you're not familiar with SQL*Plus, it's a command-line tool for connecting to Oracle databases that has been a standard part of Oracle for a long time and it is included with Oracle XE.
When connecting to an Oracle database using JDBC, you don't connect to the database directly. Instead, you connect to a TNS listener, which then connects you to the database. The error ORA-12505 means that the listener was up and you could connect to it, but it couldn't connect you to the database because it doesn't know that that database is up. There are two reasons for this:
the database has not been started up,
the database has not registered with the listener, e.g. because the database was started before the listener. (When the database starts, it registers itself with a listener if it is already running. If the listener isn't running, the database doesn't register itself, and if the listener starts, it doesn't go looking for databases that might register with it.)
ORA-12505 means that the listener knows about that database, but the listener hasn't received a notification from the database that the database is up. (If you were trying to connect to the wrong database, using the wrong SID, you would get an ORA-12154 error "TNS: could not resolve the connect identifier specified".)
What Oracle services are running in the Services snap-in? (Open this from Control Panel > Administrative Tools > Services, or just Start > Run > services.msc.) You need the services OracleServiceXE and OracleXETNSListener to be running.
If the services have both been started, can you connect to the database in SQL*Plus using any of the following at a command prompt? (I'm assuming you're running these on the machine you've installed Oracle XE on.)
sqlplus system/system-password#XE
sqlplus system/system-password
sqlplus / as sysdba
(Replace system-password with the password you set for the SYS and SYSTEM users during the Oracle XE installation.)
The first of these three connect via the TNS listener, but the second two connect directly to the database without going via the listener, and only work if you're on the same machine as the database. If the first one fails but the other two succeed, then JDBC connections will also fail. If so, connect to the database using either of the other two and run ALTER SYSTEM REGISTER. Then exit from SQL*Plus and try the first form again.
If the third one fails but the second one works, add your user account to the ora_dba group. Do this in Control Panel > Computer Management > Local Users and Groups.
Once you can get connections of the form
sqlplus system/system-password#XE
to work, you ought to be able to connect to Oracle XE via JDBC. (Incidentally, you haven't shown us the JDBC code you're using to connect to the database, but I would suspect that it is quite probably correct; there would be various other errors if parts of the connection string were wrong.)
I too got the same error but when tried all the three of them failed.
If the above three fails.Try LSNRCTL status if you find the service (XE in my case)missing try this
sqlplus /nolog
conn system
alter system register;
exit
lsnrctl status
Now you can see the service
Even if don't see try this one out
sqlplus /nolog
conn system
alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' scope = both;
alter system register;
exit
lsnrctl status
This should probably work ...
When your getting this error "ORA-12505, TNS:listener does not currently know of SID given in connect descriptor"
Solution: Open Services, and start OracleServiceXE, after that try to connect...
If you have a working connection in Oracle SQL Developer, use the information on the connection menu to build your url, as described in the following image:
In the above example, the url would be : jdbc:oracle:thin:#ORADEV.myserver.com:1521/myservice
Note that if your are using a SID, then there is a colon (":") instead of a slash ("/") after the host name.
I found some reasons for this exception.they are
1)The name of the database XE by default.so the url will be"jdbc:oracle:thin:#localhost:1521:XE".
2)Make sure that OracleServiceXE,OracleXETNSListener is running.it will be in Control Panel\All Control Panel Items\Administrative Tools\Services
I solved this issue by correcting my JDBC code.
the correct JDBC string should be...
conection = DriverManager.getConnection
("jdbc:oracle:thin:#localhost:1521:xe","system","ishantyagi");
But the JDBC string I was using was ...
conection = DriverManager.getConnection
("jdbc:oracle:thin:#localhost:1521:orcl","system","ishantyagi");
So, the mistake of specifying orcl instead of xe showed this error as the SID name was wrong.
My issue is resolved when I use the below code:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:#IPAddress:1521/servicename","userName","Password");
Faced similar error, any of the above solutions didn't help.
There was a problem in the listner.ora file. By mistake I had added SID out of the SID_LIST see below(section between the stars *).
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
*(SID_DESC =
(SID_NAME = XE)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
)*
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
Corrected this error as below:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = XE)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
Stopped and the database
Stopped the listeners OracleServiceXE and OracleXETNSListener manually as it did not stop automatically by going to Control Panel\All Control Panel Items\Administrative Tools\Services. Restarted the database and it worked like a charm.
Oracle:
Thin-style Service Name Syntax
Thin-style service names are supported only by the JDBC Thin driver. The syntax is:
#//host_name:port_number/service_name
http://docs.oracle.com/cd/B28359_01/java.111/b31224/urls.htm#BEIDHCBA
i initially came here with the same problem. I had jus installed Oracle 12c on Windows 8 (64-bit),but i have since resolved it by 'TNSPING xe' on the command line... If the connection isn't established or name not found,try the database name,in my case it was 'orcl'... 'TNSPING orcl' again and if it pings successfully then u need to change the SID to 'orcl' in this case (or whatever database name u used)...
One possibility that I haven't seen widely discussed is that there may be a problem resolving the hostname on the host machine itself. If there is no entry for $(hostname) in /etc/hosts, the Oracle listener gets confused and wont come up.
That turned out to be my problem, and adding the hostname and ip address in /etc/hosts resolved the problem.
I have faced the same issue and solved by restart the OracleServiceXE service. Goto Services.msc and then verify the 'OracleServiceXE' service is UP and running
I fixed this issue by changing "SID" to "SERVICE_NAME" in my TNSNAMES.ora file.
Please see if your DB asks for SID or SERVICE_NAME.
Cheers
Connection con=DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521:xe","scott","tiger");
Error I got:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:xe
How I solved it:
Connection con=DriverManager.getConnection("jdbc:oracle:thin:localhost:1521:xe","scott","tiger");
(Remove #)
Don't know why, but its working now...
I too faced the same issue. I had installed Oracle Express edition 10g in Windows XP OS using VMware and it was working fine. Since it was very awkward typing SQL queries in the SQL utility provided by 10g and since I was used to working with SQL developer, I installed 32 bit SQL developer in XP and tried connecting to my DB SID "XE". But the connection failed with error-ORA-12505 TNS listener doesn't currently know of SID given in connect descriptor. I was at sea as to how this problem occurred since it was working fine with the SQL utility and I had also created few Informatica mappings using the same. I did browse a lot on this stuff hither thither and applied the suggestions offered to me after pinging the status of "lsnrctl" on public forums but to no avail. However, this morning I tried creating a new connection again, and Voila, it worked with no issues. I am guessing after reading in few posts that sometimes listener listens before the DB connects or something(pardon me for my crude reference as I am a newbie here) but I suggest to just restart the machine and check again.
I had the same problem so to resolve this problem I first reconfigure my listener using netca after that I deleted my old database which was ORCL by using dbca and then i created the new database again using dbca
Please check both OracleServiceXE and OracleXETNSListener having the status started when you navigate through start->run->services.msc.
For my case only OracleXETNSListener was started but OracleServiceXE was not started, when I started by right clicking -> start and checked the connection its working for me
If you use Oracle Express Edition, you should have this url
jdbc:oracle:thin:#localhost:1521:xe or jdbc:oracle:thin:#localhost:1521/XE
I had similar problem with liquibase config plugin in pom.xml. And I changed my configuration:
`<configuration>
<driver>oracle.jdbc.OracleDriver</driver>
<url>jdbc:oracle:thin:#localhost:1521:xe</url>
<defaultSchemaName></defaultSchemaName>
<username>****</username>
<password>****</password>
</configuration>`
Check by doing tnsping and instance name in host machine. It will give u the tns decription and all most of the time host name is different which is not matching.
I resolve my issue likewise
In Unix machine
$ tnsping (Enter)
It gives me full tns description where I found that host name is different.. :)
I had similar problem in SQL Workbench.
URL:
jdbc:oracle:thin:#111.111.111.111:1111:xe
doesn't work.
URL:
jdbc:oracle:thin:#111.111.111.111:1111:asdb
works.
This help me in my concrete situation. I afraid, that could exists many other reasons with different solutions.
I got this error ORA-12505, TNS:listener does not currently know of SID given in connect descriptor when I tried to connect to oracle DB using SQL developer.
The JDBC string used was jdbc:oracle:thin:#myserver:1521/XE, obviously the correct one and the two mandatory oracle services OracleServiceXE, OracleXETNSListener were up and running.
The way I solved this issue (In Windows 10)
1. Open run command.
2. Type services.msc
3. Find services with name OracleServiceXE and OracleXETNSListener in the list.
4. Restart OracleServiceXE service first. After completing the restart try restarting OracleXETNSListener service.
Had a similar issue. The issue started occurring suddenly - we are having load balanced database connection URL, but in jdbc connections I was pointing to a single db directly.
Changed to load balanced db url and it worked.
In my case not was working out, finally i restarted my oracle and TNS listener and everything worked. Was struggling for 2 days.
Apart from running services(OracleServiceXE,OracleXETNSListener) on there is a chance your Anti-virus software/firewall may still block them. Just make sure they are not blocked.
I just fixed it by restarting / starting oracleService in services
My oracle stopped working and I was getting this error. I restarted my machine and also tried above solutions. Ultimately, I opened component services and restarted the oracle services and it all started working. Hope this helps someone.
I was just creating the database link incorrectly.
Simple fix for me was to simply change 'SID' to SERVICE_NAME
CREATE DATABASE LINK my_db_link
CONNECT TO myUser IDENTIFIED BY myPassword
USING
'
(
DESCRIPTION=
(
ADDRESS=
(PROTOCOL=TCP)
(HOST=host-name-heren)
(PORT=1521)
)
(CONNECT_DATA=(SID=theNameOfTheDatabase))
)';
Changing
SID=theNameOfTheDatabase
to
SERVICE_NAME=theNameOfTheDatabase
resolved my issue.
I encounter this problem because I did kill task to "Oracle" task in the Task Manager.
To fix it you need to open the cmd -> type: services.msc -> the window with all services will open -> find service "OracleServiceXE" -> right click: start.
#Luke Woodward's answer helped to identify my XE wasn't connecting.
I had an issue when connecting to a VPN. And I am using a fresh local Oracle 21c on Windows 11.
The files listener.ora and tnsnames.ora were using my PC name "ERIK-PC" like this:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ERIK-PC)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
I just needed to change ERIK-PC to localhost.
More information in this thread.
By the way, I am using Oracle 21c, and since 18c, the *.ora files are under installationfolder\homes\OraDB21Home1\network\admin\*.ora
Save your changes and restart the listener using a privileged windows shell:
lsnrctl stop
lsnrctl start

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

I have installed Oracle 11g Express Edition Release 2 in my windows 7 64 bit OS and tried to execute JDBC program, then I got the following error:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.jlcindia.jdbc.JDBCUtil.geOracleConnection(JDBCUtil.java:28)
at Lab3O.main(Lab3O.java:15)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:385)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
... 8 more
I fixed this issue by correcting my jdbc string.
For example, the correct jdbc string should be...
jdbc:oracle:thin:#myserver:1521/XE
But the jdbs string I was using is ...
jdbc:oracle:thin:#myserver:1521:XE
(Note: between 1521 and XE should be a /)
This bad jdbc string give me a ORA-12505 error too.
There are a few things that can cause this problem, but before you get started with JDBC, you need to be sure that you can connect to the database using SQL*Plus. If you're not familiar with SQL*Plus, it's a command-line tool for connecting to Oracle databases that has been a standard part of Oracle for a long time and it is included with Oracle XE.
When connecting to an Oracle database using JDBC, you don't connect to the database directly. Instead, you connect to a TNS listener, which then connects you to the database. The error ORA-12505 means that the listener was up and you could connect to it, but it couldn't connect you to the database because it doesn't know that that database is up. There are two reasons for this:
the database has not been started up,
the database has not registered with the listener, e.g. because the database was started before the listener. (When the database starts, it registers itself with a listener if it is already running. If the listener isn't running, the database doesn't register itself, and if the listener starts, it doesn't go looking for databases that might register with it.)
ORA-12505 means that the listener knows about that database, but the listener hasn't received a notification from the database that the database is up. (If you were trying to connect to the wrong database, using the wrong SID, you would get an ORA-12154 error "TNS: could not resolve the connect identifier specified".)
What Oracle services are running in the Services snap-in? (Open this from Control Panel > Administrative Tools > Services, or just Start > Run > services.msc.) You need the services OracleServiceXE and OracleXETNSListener to be running.
If the services have both been started, can you connect to the database in SQL*Plus using any of the following at a command prompt? (I'm assuming you're running these on the machine you've installed Oracle XE on.)
sqlplus system/system-password#XE
sqlplus system/system-password
sqlplus / as sysdba
(Replace system-password with the password you set for the SYS and SYSTEM users during the Oracle XE installation.)
The first of these three connect via the TNS listener, but the second two connect directly to the database without going via the listener, and only work if you're on the same machine as the database. If the first one fails but the other two succeed, then JDBC connections will also fail. If so, connect to the database using either of the other two and run ALTER SYSTEM REGISTER. Then exit from SQL*Plus and try the first form again.
If the third one fails but the second one works, add your user account to the ora_dba group. Do this in Control Panel > Computer Management > Local Users and Groups.
Once you can get connections of the form
sqlplus system/system-password#XE
to work, you ought to be able to connect to Oracle XE via JDBC. (Incidentally, you haven't shown us the JDBC code you're using to connect to the database, but I would suspect that it is quite probably correct; there would be various other errors if parts of the connection string were wrong.)
I too got the same error but when tried all the three of them failed.
If the above three fails.Try LSNRCTL status if you find the service (XE in my case)missing try this
sqlplus /nolog
conn system
alter system register;
exit
lsnrctl status
Now you can see the service
Even if don't see try this one out
sqlplus /nolog
conn system
alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' scope = both;
alter system register;
exit
lsnrctl status
This should probably work ...
When your getting this error "ORA-12505, TNS:listener does not currently know of SID given in connect descriptor"
Solution: Open Services, and start OracleServiceXE, after that try to connect...
If you have a working connection in Oracle SQL Developer, use the information on the connection menu to build your url, as described in the following image:
In the above example, the url would be : jdbc:oracle:thin:#ORADEV.myserver.com:1521/myservice
Note that if your are using a SID, then there is a colon (":") instead of a slash ("/") after the host name.
I found some reasons for this exception.they are
1)The name of the database XE by default.so the url will be"jdbc:oracle:thin:#localhost:1521:XE".
2)Make sure that OracleServiceXE,OracleXETNSListener is running.it will be in Control Panel\All Control Panel Items\Administrative Tools\Services
I solved this issue by correcting my JDBC code.
the correct JDBC string should be...
conection = DriverManager.getConnection
("jdbc:oracle:thin:#localhost:1521:xe","system","ishantyagi");
But the JDBC string I was using was ...
conection = DriverManager.getConnection
("jdbc:oracle:thin:#localhost:1521:orcl","system","ishantyagi");
So, the mistake of specifying orcl instead of xe showed this error as the SID name was wrong.
My issue is resolved when I use the below code:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc:oracle:thin:#IPAddress:1521/servicename","userName","Password");
Faced similar error, any of the above solutions didn't help.
There was a problem in the listner.ora file. By mistake I had added SID out of the SID_LIST see below(section between the stars *).
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
*(SID_DESC =
(SID_NAME = XE)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
)*
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
Corrected this error as below:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = XE)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
Stopped and the database
Stopped the listeners OracleServiceXE and OracleXETNSListener manually as it did not stop automatically by going to Control Panel\All Control Panel Items\Administrative Tools\Services. Restarted the database and it worked like a charm.
Oracle:
Thin-style Service Name Syntax
Thin-style service names are supported only by the JDBC Thin driver. The syntax is:
#//host_name:port_number/service_name
http://docs.oracle.com/cd/B28359_01/java.111/b31224/urls.htm#BEIDHCBA
i initially came here with the same problem. I had jus installed Oracle 12c on Windows 8 (64-bit),but i have since resolved it by 'TNSPING xe' on the command line... If the connection isn't established or name not found,try the database name,in my case it was 'orcl'... 'TNSPING orcl' again and if it pings successfully then u need to change the SID to 'orcl' in this case (or whatever database name u used)...
One possibility that I haven't seen widely discussed is that there may be a problem resolving the hostname on the host machine itself. If there is no entry for $(hostname) in /etc/hosts, the Oracle listener gets confused and wont come up.
That turned out to be my problem, and adding the hostname and ip address in /etc/hosts resolved the problem.
I have faced the same issue and solved by restart the OracleServiceXE service. Goto Services.msc and then verify the 'OracleServiceXE' service is UP and running
I fixed this issue by changing "SID" to "SERVICE_NAME" in my TNSNAMES.ora file.
Please see if your DB asks for SID or SERVICE_NAME.
Cheers
Connection con=DriverManager.getConnection("jdbc:oracle:thin:#localhost:1521:xe","scott","tiger");
Error I got:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:xe
How I solved it:
Connection con=DriverManager.getConnection("jdbc:oracle:thin:localhost:1521:xe","scott","tiger");
(Remove #)
Don't know why, but its working now...
I too faced the same issue. I had installed Oracle Express edition 10g in Windows XP OS using VMware and it was working fine. Since it was very awkward typing SQL queries in the SQL utility provided by 10g and since I was used to working with SQL developer, I installed 32 bit SQL developer in XP and tried connecting to my DB SID "XE". But the connection failed with error-ORA-12505 TNS listener doesn't currently know of SID given in connect descriptor. I was at sea as to how this problem occurred since it was working fine with the SQL utility and I had also created few Informatica mappings using the same. I did browse a lot on this stuff hither thither and applied the suggestions offered to me after pinging the status of "lsnrctl" on public forums but to no avail. However, this morning I tried creating a new connection again, and Voila, it worked with no issues. I am guessing after reading in few posts that sometimes listener listens before the DB connects or something(pardon me for my crude reference as I am a newbie here) but I suggest to just restart the machine and check again.
I had the same problem so to resolve this problem I first reconfigure my listener using netca after that I deleted my old database which was ORCL by using dbca and then i created the new database again using dbca
Please check both OracleServiceXE and OracleXETNSListener having the status started when you navigate through start->run->services.msc.
For my case only OracleXETNSListener was started but OracleServiceXE was not started, when I started by right clicking -> start and checked the connection its working for me
If you use Oracle Express Edition, you should have this url
jdbc:oracle:thin:#localhost:1521:xe or jdbc:oracle:thin:#localhost:1521/XE
I had similar problem with liquibase config plugin in pom.xml. And I changed my configuration:
`<configuration>
<driver>oracle.jdbc.OracleDriver</driver>
<url>jdbc:oracle:thin:#localhost:1521:xe</url>
<defaultSchemaName></defaultSchemaName>
<username>****</username>
<password>****</password>
</configuration>`
Check by doing tnsping and instance name in host machine. It will give u the tns decription and all most of the time host name is different which is not matching.
I resolve my issue likewise
In Unix machine
$ tnsping (Enter)
It gives me full tns description where I found that host name is different.. :)
I had similar problem in SQL Workbench.
URL:
jdbc:oracle:thin:#111.111.111.111:1111:xe
doesn't work.
URL:
jdbc:oracle:thin:#111.111.111.111:1111:asdb
works.
This help me in my concrete situation. I afraid, that could exists many other reasons with different solutions.
I got this error ORA-12505, TNS:listener does not currently know of SID given in connect descriptor when I tried to connect to oracle DB using SQL developer.
The JDBC string used was jdbc:oracle:thin:#myserver:1521/XE, obviously the correct one and the two mandatory oracle services OracleServiceXE, OracleXETNSListener were up and running.
The way I solved this issue (In Windows 10)
1. Open run command.
2. Type services.msc
3. Find services with name OracleServiceXE and OracleXETNSListener in the list.
4. Restart OracleServiceXE service first. After completing the restart try restarting OracleXETNSListener service.
Had a similar issue. The issue started occurring suddenly - we are having load balanced database connection URL, but in jdbc connections I was pointing to a single db directly.
Changed to load balanced db url and it worked.
In my case not was working out, finally i restarted my oracle and TNS listener and everything worked. Was struggling for 2 days.
Apart from running services(OracleServiceXE,OracleXETNSListener) on there is a chance your Anti-virus software/firewall may still block them. Just make sure they are not blocked.
I just fixed it by restarting / starting oracleService in services
My oracle stopped working and I was getting this error. I restarted my machine and also tried above solutions. Ultimately, I opened component services and restarted the oracle services and it all started working. Hope this helps someone.
I was just creating the database link incorrectly.
Simple fix for me was to simply change 'SID' to SERVICE_NAME
CREATE DATABASE LINK my_db_link
CONNECT TO myUser IDENTIFIED BY myPassword
USING
'
(
DESCRIPTION=
(
ADDRESS=
(PROTOCOL=TCP)
(HOST=host-name-heren)
(PORT=1521)
)
(CONNECT_DATA=(SID=theNameOfTheDatabase))
)';
Changing
SID=theNameOfTheDatabase
to
SERVICE_NAME=theNameOfTheDatabase
resolved my issue.
I encounter this problem because I did kill task to "Oracle" task in the Task Manager.
To fix it you need to open the cmd -> type: services.msc -> the window with all services will open -> find service "OracleServiceXE" -> right click: start.
#Luke Woodward's answer helped to identify my XE wasn't connecting.
I had an issue when connecting to a VPN. And I am using a fresh local Oracle 21c on Windows 11.
The files listener.ora and tnsnames.ora were using my PC name "ERIK-PC" like this:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ERIK-PC)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
I just needed to change ERIK-PC to localhost.
More information in this thread.
By the way, I am using Oracle 21c, and since 18c, the *.ora files are under installationfolder\homes\OraDB21Home1\network\admin\*.ora
Save your changes and restart the listener using a privileged windows shell:
lsnrctl stop
lsnrctl start

TNS:name lookup failure

I have a stand-alone workstation at work that connects to an oracle database. It's been working fine for years and then all of sudden I get an error:
[INTERSOLV][ODBC Oracle driver][Oracle]ORA-12545: TNS:name lookup failure
When I ping the server I am trying to connect to from the command prompt, it replies back with the right IP address. If I do a TNSPING, that seems to be ok as well.
I have a separate PC that is on the computer network and it connects to the server just fine - it doesn't have that error above in bold.
There is another, different oracle database that I connect to on that stand-alone PC and it's still working fine. So, it's not like I lost the ability to connect to any or all Oracle databases - just something about this one.
I'm confused why it won't work and haven't had any luck trying to fix it. I'm not sure how to proceed.
Any help would be appreciated.
Try defining the environment variable TNS_ADMIN to point at the location where your TNSNAMES.ORA file resides.
EDIT:
Can you connect with SQL*Plus directly?
If it's installed, this should work (replace user and db with the userid and database to conenct to):
sqlplus user#db
Failing that, try connecting with EZCONNECT:
Modify sqlnet.ora file:
NAMES.DIRECTORY_PATH=(TNSNAMES,EZCONNECT)
Change your ODBC Connection in the Oracle ODBC Driver Configuration wizard to use the EZCONNECT string:
Replace the TNS Service Name with:
<db_host>:port/<db_name>
e.g.,
MYHOST:1521/MYDB
This points to the database MYDB on host MYHOST at port 1521 (the default port).
Try testing the connection. If that fails, try using the IP address instead of the hostname.
Given your TNSNAMES entry from your comments:
ESTRNP = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ESTRNP)(PORT = 1521))
)
(CONNECT_DATA = (SID = ESTRNP))
)
You might try changing the CONNECT_DATA line to:
(CONNECT_DATA = (SERVICE = ESTRNP))
It is possible that the SID of the database was changed. Is this entry the same as the entry on the machine that works?
do you have recently install any other oracle software?
It is possible that you have multiple tnsnames.ora files on different locations and the odbc driver finds the wrong one.
Inspect you path environment variable, whether the path to the right one is at the first place.

Connect to an Oracle DB using ODBC

I am developing an application that needs to interract with a "lightly documented" Legacy Oracle Database. To Start that process I want to start creating a view into that Database using ODBC links into an MS Access database so I can figure out the DB structure but I can't figure out how to setup the ODBC connection to the Oracle DB.
I have been able to connect using the Host and Service Name to and view the DB using SQL Developer; but, I can't figure out how to setup ODBC. I am running Windows 7 and have installed Oracle 11g, Oracle Express Edition, the Instant Client and ODBC extensitons; but on the ODBC setup Oracle wants me to pick a TNS Service Name but there is none to pick and there is no place to specify the host. I tried to setup a TNS in tnsnames.ora; but I am not really sure I know the right location for that file.
I really thought this would be the easy part; but, it really hasn't been.
Navigate to the Control Panel > Administrative Tools > Data Sources (ODBC)
Select the System DSN tab and click 'Add'. Next scroll down the lists of drivers until you find Microsoft ODBC for Oracle.
Fill in the required information in the above form and click 'OK'. Now you can add the tables to 'Access' by clicking on the 'External Data' tab then clicking on 'More'. Choose 'ODBC Databases', then 'Import the source data...', next click on the 'Machine Data Source' tab.
The simplest option to generate the tnsnames.ora file is to let Oracle do it. If you launch the Oracle Net Configuration Assistant (Start | Oracle in Oracle Home Name | Configuration and Migration Tools | Net Configuration Assistant), you should be able to choose "Local Net Service Name configuration" which allows you to add (or modify) a TNS alias. That will walk you through gathering the information you'll need to connect.
If you are more comfortable dealing with the text files directly, you can directly edit the tnsnames.ora file in %Oracle Home%\network\ADMIN\tnsnames.ora using this as a template.
<TNS alias> =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <hostname or IP>)(PORT = <port>))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <database service name>)
)
)
In tnsnames.ora, try changing SERVICE_NAME to SID. That worked for me.
My Experience
1. TNSNAMES.ORA is as follows.
XE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 192.168.2.116)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SERVICE_NAME = XE)
)
)
Set Windows Environment Variables (ControlPanel --> System --> Detail..)
2-1. Add to PATH
c:\oraclexe\instantclient_11_2\ --- install directory of instantclient
2-2. Add New Environment Variable
TNS_ADMIN c:\oraclexe\instantclient_11_2\ --> install directory
NLS_LANG = JAPANESE_JAPAN.JA16SJISTILDE
Windows command prompt
cd c:\Windows\SysWow64 <--I use 32bit ODBC in 64bit Win7
odbcad32.exe
  Name : ICODBC <-- as you like
Service Name : XE
User Name: system
Press Connection Test Button

Unreliable Oracle connection (intermittent error "Connect failed because target host or object does not exist")

We recently changed physical DB's, new servers, new locations, same database schema and data and since the change over, whenever we try to connect directly to the DB in our own desktop type applications about half of the time we get this error:
SQL*Loader-704: Internal error: ulconnect: OCIServerAttach[0]
ORA-12545: Connect failed because target host or object does not exist
The rest of the time, it connects right away without any issues. Our applications that establish connections via JDBC don't seem to have any issues but we do when going through something that does a tnsnames.ora lookup (or that's my hunch at least). TNSPING works 100% but using an oracle executable like SQLLDDR fails at least 50% of the time. Here's an anonymized snppet of our TSNNAMES file and a TNSPING output:
DB_CONNECTION =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 1.2.3.4)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = MY.URL.COM)
)
)
And the TNSPING:
C:\>TNSPING DB_CONNECTION
TNS Ping Utility for 32-bit Windows: Version 9.2.0.1.0
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
C:\oracle\ora92\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 1.2.3.4)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = MY.URL.COM)))
OK (200 msec)
I have the SID of the DB, which is what the JDBC connections rely on but adding it to the tnsnames.ora doesn't improve the odds of making a connection. I don't know enough about how the tnsnames file is being used by Oracle to intelligently resolve this issue. What can I try?
Edit
The new DB's may be two load balanced databases which may be part of the problem.
We recently had a similar issue with our application. The application would sometimes connect to the Oracle RAC and sometimes it would complain with ORA-12545.
In short the issue was that the server had a real name while we were using virtual IP addresses in TNSNAMES.ORA. Once we added the mapping of the server name to IP address via system32\drivers\etc\hosts file everything started to work properly.
I have written a bit more in my blog
<shameless advert>http://dcarapic.blogspot.com/2009/04/intermittent-ora-12545-error.html</shameless advert>
Ah, gotta love the intermittent problems :)
(In the following I have had to replace the underscore character as I don't know the escape char for this wiki language)
Are you always using the same OS user to connect and to do the tnsping?
Check for environment variables TNS[underscore]ADMIN pointing to different tnsnames.ora locations. Do a scan of the client for duplicate tnsnames.ora; either in locations pointed to by $TNS[underscore]ADMIN or in different $ORACLE[underscore]HOMES (e.g. if you have 2 Oracle client installs).
Likewise check that you are using the same $ORACLE[underscore]HOME and $PATH environment variables for all connection attempts and tnsping. (E.g. always the same OS user or each user has the same values)
I see that the tnsping output reports version 9.2 so this is not likely, but in 11g the DB registers with the listener which can take a minute or so. (maybe also true with 10g). Attempts to connect prior to this will not find the target.
Another unlikely possibility - is a service with the same service name still advertised on the old host server? Remove it if at all possible.
After that I would start to look at the network itself. Is a ping of the server always successful and quick? If you're using the hostname rather than IP in the tnsnames.ora, does the hostname reliably resolve to the correct IP (nslookup). Is there a local firewall and if so is it behaving?
Regards
Karl
If you are using Oracle 10g, you may use an Easy Connect handler instead:
//servername/instancename
,
//1.2.3.4/my.url.com
in your case.
It's immune to lots of TNSNAMES issues.

Resources