Error ORA-12505 when connecting to Database Oracle 11g SQL Developer

oracle-11g

recently I installed Oracle XE 11g with SQL Developer.

When I first ran it and created a database and a new user, everything worked perfectly – I was able to connect to the database and was able to run queries and scripts.
However, when I restart my laptop (for example, the following day), I am unable to connect to my database using that new user I created, as well as unable to use SYS/SYSTEM accounts.
I get an error with the code ORA-12505 that states:

"An error was encountered performing the requested operation:

Listener refused the connection with the following error:

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

Vendor code 12505".

Nothing has changed since I restarted my laptop! I have also Googled the error but I am still unable to solve it. I know the error has something to do with my 'tnsnames.ora' file, but the service_name is correct from what I can tell.

My tnsnames.ora file is as follows:

  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Mark-Prescher-Laptop)(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) 
    ) 
  ) 

Error when trying to create a database

Error when trying to connect to an existing database

Thank you for any help in advance!

Best Answer

The way you are connecting to the database (connection type "basic") isn't using your tnsnames.ora file at all. It is using a basic JDBC connect string - which is fine. That said, the error indicates that the database "xe" hasn't registered with the listener, meaning that the database itself probably isn't running at all. Check to make sure that your database instance is actually up. Check this document for details: https://docs.oracle.com/cd/E17781_01/admin.112/e18585/toc.htm#XEGSG101

Related Question