Sub topic 5
Creating a Basic connection in SQL Developer
This chapter shows how to create, test, and save a Basic connection in SQL Developer. It assumes you know what a host, port, and service name are (covered in the earlier chapters on the connection model and connect identifiers). It also assumes you have a reachable Oracle Database, an account on it, and SQL Developer installed with a Java runtime, or a SQL Developer download that bundles one.
What a Basic connection is
SQL Developer offers several connection types. A Basic connection is the one where you fill in separate fields for each part of the connection: host name, port, and either a service name or a SID. SQL Developer then builds the connect descriptor for you.
Use Basic when you know the host, port, and service name and do not have a tnsnames.ora file. Use the TNS type (next chapter) when your organization maintains aliases in tnsnames.ora.
The Basic fields map directly to the Easy Connect string you already know:
| Basic field | Easy Connect equivalent | Example |
|---|---|---|
| Hostname | host | `dbhost.example.com` |
| Port | port | `1521` |
| Service name | service name after the `/` | `orclpdb1.example.com` |
| Username | user before the `@` | `hr` |
| Password | prompted | not part of the string |
Together, these give //dbhost.example.com:1521/orclpdb1.example.com. The JDBC thin URL for the same target is:
jdbc:oracle:thin:@//dbhost.example.com:1521/orclpdb1.example.comSQL Developer uses JDBC internally, so this URL is what it effectively connects with.
How the connection is built
The order matters for troubleshooting. A failure at the listener step tells you nothing about your password, and a password error tells you the network path and service name are already correct.
Creating the connection step by step
- Start SQL Developer. In the Connections panel on the left, click the green + icon (New Connection). If the panel is hidden, use View > Connections.
- In the New / Select Database Connection dialog, enter a Name. This is only a label for you. Use something that identifies the database and user, such as
orclpdb1_hr. - Enter the Username, for example
hr. - Enter the Password. Decide whether to tick Save Password (see the security note below).
- Make sure Connection Type is Basic.
- Enter Hostname:
dbhost.example.com. - Enter Port:
1521, unless your administrator told you otherwise. - Select Service name and enter
orclpdb1.example.com. Do not use the SID option unless you know the database registers only a SID (see below). - Click Test. The Status line at the bottom left of the dialog shows
Successor an error message. - Click Save, then Connect.
A worksheet opens, connected to the database. The connection name appears in the Connections panel, and you can reopen it later by double-clicking it.
Service name versus SID
The dialog offers both SID and Service name radio buttons. Prefer Service name. Current Oracle Database releases, and every pluggable database (PDB), are reached through a service name. A SID identifies only the database instance, and a PDB has no SID of its own. If you enter a CDB's SID when you meant to reach a PDB, you connect to the root container instead of your application data.
Use SID only for older databases that your administrator confirms are reached that way.
Common default values
Several values depend on the environment. These are typical, not guaranteed:
- Port
1521is the default listener port. Containers and cloud services sometimes map it to a different host port, such as1522or51521. - Oracle Database Express Edition and many Docker images use a service name such as
XEPDB1for the pluggable database. - A service name often includes a domain suffix (
.example.com). Whether it appears depends on the database'sDB_DOMAINsetting. Copy the name from your administrator rather than guessing.
Password storage and security
The Save Password checkbox stores the password so you do not retype it. SQL Developer encrypts saved passwords in its connection store, but this protects them only against casual viewing. Anyone who can use your operating system account and your SQL Developer settings can open the connection.
If you leave Save Password cleared, SQL Developer prompts for the password every time you connect. For shared machines and for any account with broad privileges, leave it cleared.
The Role field and other options
Below the main fields you may see a Role drop-down with the value default. You set it to SYSDBA or SYSOPER only when connecting as a privileged user. That topic has its own chapter. For a normal schema account like hr, leave it as default.
Other options in the dialog:
- Connection Color tints the worksheet so you can tell production from test at a glance. Set it for every production connection.
- OS Authentication and Kerberos Authentication replace the password with a ticket or operating system identity. They are configured by the database administrator and are not used with a plain Basic connection.
- Proxy User lets you connect through another account. It is a specialist option.
Verifying the session
A successful Test only proves that you reached a database with valid credentials. It does not prove you reached the intended one. After connecting, run this in 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;Press Ctrl+Enter to run the statement at the cursor. The result appears in the Query Result tab. Compare the three columns with what you typed in the dialog. Note that SERVER_HOST returns the name the server knows for itself. In containers or behind load balancers it can differ from the host name you entered, and that is normal.
Editing, copying, and organizing connections
To change a saved connection, right-click it in the Connections panel and choose Properties. You can also choose Connect from the same menu. If you change the host or service name, test again before saving.
To create several similar connections, such as the same database with a different user, right-click an existing connection and choose Duplicate (or Save As from the edit dialog on some versions), then change the name and username. This keeps the host, port, and service name consistent.
Connections can be exported to a JSON file with Export Connections from the right-click menu on the Connections node. Exporting lets you move connections to another machine. The wizard asks whether to include passwords. Exclude them unless the file will be stored securely, because exported credentials are a leakage risk.
Troubleshooting a Basic connection
The Test status message names the failure. Match it to the stage in the diagram.
| Message | Meaning | What to check |
|---|---|---|
| `ORA-12541: TNS:no listener` or `Connection refused` | Nothing is listening at that host and port | Host spelling, port, whether the listener is running, firewalls, container port mapping |
| `ORA-12514: TNS:listener does not currently know of service requested` | The listener is reachable but the service name is not registered | Service name spelling, domain suffix, whether the database or PDB is open |
| `ORA-01017: invalid username/password; logon denied` | Network and service are correct, credentials are not | Username, password, case, account lock status |
| `ORA-28000: the account is locked` | The account was locked by the administrator or failed attempts | Ask the administrator to unlock it |
| `The Network Adapter could not establish the connection` | JDBC could not open a TCP connection at all | Host name resolution, VPN, firewall |
Do not retry a password several times after an ORA-01017. Repeated failures can lock the account under the default profile. Fix the other fields first, then try once. Note that the dialog can hold a stale password from an earlier save, so retype it when in doubt.
If the Test succeeds but the connection fails later with a timeout, a firewall or idle-connection policy is usually closing the session. This is not a Basic connection problem and you should raise it with the network administrator.
Summary of the workflow
- Gather host, port, service name, username, and password from your administrator.
- Create a Basic connection and give it a descriptive name.
- Choose Service name, not SID.
- Test, save, and connect.
- Run the verification query and compare the result with your expectation.
- Set a connection color for any production target.
Exercise
You enter a host and port correctly, choose Service name, and click Test. The status reads ORA-12514: TNS:listener does not currently know of service requested. Which field is the most likely cause, and why can you rule out the password?
Show answer
The service name is the most likely cause (a typo, a missing or extra domain suffix, or a PDB that is not open). You can rule out the password because the error comes from the listener, which is contacted before authentication happens. The credentials are not checked until the service is found.
Exercise
After connecting, the verification query returns a SERVICE_NAME you did not expect, and the tables you need are missing. What do you check in the connection dialog, and what likely went wrong?
Show answer
Check the Service name field (and whether SID was selected instead). You probably connected to the container root or a different PDB than intended. Edit the connection to use the service name of the correct PDB, then reconnect and rerun the query.