Sub topic 5
Creating a Basic Connection in SQL Developer
Assume you understand tables and simple SQL, can use your operating system’s file manager, and have access to a reachable Oracle Database. You also need an Oracle username and password, the database host name, the listener port, and the database service name.
A SQL Developer connection is a saved set of details that tells the tool where to connect and which account to use. A Basic connection stores these details directly in SQL Developer rather than looking up a named entry in tnsnames.ora.
Gather the connection details
Before opening SQL Developer, obtain the values from your database administrator or cloud provider.
| SQL Developer field | Purpose | Example |
|---|---|---|
| Connection Name | Label shown in SQL Developer | `HR development` |
| Username | Database account | `HR` |
| Password | Password for that account | Your private password |
| Hostname | Computer running Oracle or its network address | `dbhost.example.com` |
| Port | Listener port | `1521` |
| Service name | Database service requested from the listener | `orclpdb1.example.com` |
The port is often 1521, but do not assume it. The service name identifies the database service. In a multitenant database, it commonly identifies a pluggable database service.
Create the Basic connection
- Start SQL Developer.
- Open the Connections panel. If it is hidden, select View > Connections.
- Click the green plus icon, or right-click Connections and select New Connection.
- Enter a descriptive Connection Name, such as
HR development. - Enter the database Username.
- Enter the Password. Leave Save Password cleared on shared computers.
- Set Connection Type to Basic.
- Enter the Hostname, Port, and Service name.
- Leave Role as Default for a normal application or development account.
- Click Test.
The test checks whether SQL Developer can reach the listener and authenticate the account. A successful test displays Status: Success. Click Connect to open the worksheet.
select sys_context('USERENV', 'SESSION_USER') as session_user,
sys_context('USERENV', 'SERVICE_NAME') as service_name,
sys_context('USERENV', 'SERVER_HOST') as server_host
from dual;Run this query in the worksheet after connecting. It reports the account, service, and server host used by the current session. This check is useful when several databases have similar names.
Understand the connection flow
Common mistakes
- Wrong hostname: The computer name cannot be resolved, or it points to a different server.
- Wrong port: The listener is running on another port or is blocked by a firewall.
- Wrong service name: The listener is reachable but does not offer the requested service.
- Wrong credentials: The username or password is incorrect, or the account is locked.
- Wrong database: A valid connection can still reach an unintended environment. Always run the verification query before changing data.
Exercise
Which Basic connection field identifies the database service that the listener should open for your session?
Show answer
The Service name field. It is different from the hostname, which identifies the server, and the port, which identifies the listener endpoint.