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

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

I fixed this issue by correcting my jdbc string.

For example, the correct jdbc string should be…


But the jdbs string I was using is …


(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 youre not familiar with SQL*Plus, its 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 dont 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 couldnt connect you to the database because it doesnt 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 isnt running, the database doesnt register itself, and if the listener starts, it doesnt go looking for databases that might register with it.)

ORA-12505 means that the listener knows about that database, but the listener hasnt 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? (Im assuming youre running these on the machine youve 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 youre 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 havent shown us the JDBC code youre 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.)

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

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;  
lsnrctl status  

Now you can see the service
Even if dont 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;  
lsnrctl status

This should probably work …

Leave a Reply

Your email address will not be published.