Skip to Main Content
  • Questions
  • Unable to connect to database xe using sql developer

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Pooyan.

Asked: April 03, 2020 - 7:20 pm UTC

Last updated: March 25, 2024 - 5:01 am UTC

Version: 19.4.0.354.1759

Viewed 10K+ times! This question is

You Asked

Hi ,

I am unable to connect to oracle database using SQL DEVELOPER. It gives me" i/o error network adapter could not establish connection". Please let me know what are the possible reasons for it and provide me the solution for the same.
- I am using sql developer Version: 19.4.0.354.1759 and Oracle XE184
- My connection type is basic to localhost:1521
- It also does not recognize my username "sys" on windows cmd
- I am a beginner in DBMS

Regards

and Connor said...

1) Make sure the listener is running

Go to Services and check for the OracleTNSListener and start it if needed

2) Make sure XE is running.

Go to Services and check for the OracleServiceXE and start it if needed

Then try the connection again. If that does not work, then

3) Fire up a command prompt and run:

lsnrctl status

It should come back with something like this:

C:\temp>lsnrctl status 

LSNRCTL for 64-bit Windows: Version 19.0.0.0.0 - Production on 06-APR-2020 08:59:55

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=15h21)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 64-bit Windows: Version 19.0.0.0.0 - Production
Start Date                20-MAR-2020 19:47:07
Uptime                    16 days 13 hr. 12 min. 47 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   C:\oracle\product\19\network\admin\listener.ora
Listener Log File         C:\oracle\diag\tnslsnr\gtx\listener19\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1519ipc)))
Services Summary...
Service "db19" has 1 instance(s).
  Instance "db19", status READY, has 1 handler(s) for this service...
Service "pdb1" has 1 instance(s).
  Instance "db19", status READY, has 1 handler(s) for this service...
The command completed successfully


Look for your the "listening endpoints" and the "services summary"

So in my case, my SQL Dev entries would then be:

host = localhost
port = 1521
service = pdb1

For XE, the service is normally XEPDB1. I suspect your listener might either be stopped or perhaps listening on a different IP address to localhost.

Rating

  (5 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Installed Oracle XE 21c but unable to connect via Oracle SQL Developer

Raja Ramani, March 22, 2022 - 4:42 am UTC

The original response seem outdated.

I downloaded and installed Oracle XE 21c and Oracle SQL Developer

All services indicated in the post are running but I am still unable to connect to the database via SQL Developer.

I am using username sysdba.
I also tried username: sys

Hostname: localhost
Port: 1521
SID: xe

when i test the connection i get
Status : Failure - Test failed: ORA-01017: Invalid username/password; login denied
Connor McDonald
March 23, 2022 - 2:23 am UTC

Couple of things

1) You want to connect to the pluggable, so choose Service = XEPDB1 not SID=XE
2) If you connect as SYS, make sure you tick the "AS SYSDBA" in the role field as well.

Then the first thing once you have connected you want to do is create yourself a user that has *reasonable* power, but not so much that you might destroy your database :-) SYS should rarely be used.

These are reasonable starting points

Development User
==============
create user mydeveloper identified by mypassword quota unlimited on users;

grant CREATE DATABASE LINK
,CREATE JOB
,CREATE MATERIALIZED VIEW
,CREATE PROCEDURE
,CREATE SEQUENCE
,CREATE SESSION
,CREATE SYNONYM
,CREATE TABLE
,CREATE TRIGGER
,CREATE TYPE
,CREATE USER
,CREATE VIEW
on mydeveloper;

Power User:
=========
create user myadmin identified by mypassword;

grant dba, execute any procedure, select any table, select any dictionary to myadmin;


why not predefined roles...

Rajeshwaran Jeyabal, March 23, 2022 - 3:07 pm UTC


grant CREATE DATABASE LINK
,CREATE JOB
,CREATE MATERIALIZED VIEW
,CREATE PROCEDURE
,CREATE SEQUENCE
,CREATE SESSION
,CREATE SYNONYM
,CREATE TABLE
,CREATE TRIGGER
,CREATE TYPE
,CREATE USER
,CREATE VIEW
on mydeveloper;


But why do you go with this set explicitly and not just make use of predefined roles. something like this " grant connect,resource,create view to mydeveloper; "

demo@XEPDB1> select privilege from role_sys_privs where role='CONNECT';

PRIVILEGE
----------------------------------------
SET CONTAINER
CREATE SESSION

demo@XEPDB1> select privilege from role_sys_privs where role='RESOURCE';

PRIVILEGE
----------------------------------------
CREATE INDEXTYPE
CREATE OPERATOR
CREATE TYPE
CREATE TRIGGER
CREATE PROCEDURE
CREATE SEQUENCE
CREATE CLUSTER
CREATE TABLE

8 rows selected.

demo@XEPDB1>

Connor McDonald
March 25, 2022 - 3:00 am UTC

"I am a beginner in DBMS"

One day they can head down the role path, but to do it initially means they'll going to be very confused the moment they run some plsql

HI

Gokul, May 28, 2023 - 11:01 am UTC

I am unable to connect to oracle database using SQL DEVELOPER. It gives me error

"status: Failure -Test failed: Listener refused the connection with the following error:ORA-12505, TNS:listener does not currently know of SID given in connect descriptor (CONNECTION_ID=sKjvhGhr TBuweT64fpbZjw==)

Using oracle 21c
Username: sys as sysdba
Connor McDonald
May 29, 2023 - 3:40 am UTC

That means you hit the host OK, and the listener responded, so it means what you put in the "SID" or "Service" name was wrong.

sql developer connection is not alive

santhuru, March 24, 2024 - 6:32 pm UTC

i created one database connection in sql developer.but after closing the sq ldeveloper the connection are gone.but my old connection are shows in recent connection but i couldnot acces it.
can anyone solved this problem.
Connor McDonald
March 25, 2024 - 5:01 am UTC

When create a new connection and hit "Connect" this creates the connection for this particular session of SQL Developer.

Make sure you hit Save when creating the connection so it persists.

More to Explore

Multitenant

Need more information on Multitenant? Check out the Multitenant docs for the Oracle Database