Sub topic 1
What an Oracle connection is made of
Prerequisites
You should know basic SQL and be comfortable in a terminal. You need a reachable Oracle Database and an account on it. This chapter assumes you can read a host name and port from your network team or your cloud console.
An Oracle connection has four parts:
- Host: the server's name or IP address.
- Port: the TCP port the listener accepts traffic on. The default is 1521.
- Service name: the logical name of the database you want.
- Credentials: a database user name and password.
Service names, SIDs, and the listener
The listener is a process on the server that receives connection requests and passes each one to the matching database service. Clients name the target by service name. Older setups used a SID, which names one database instance directly. Prefer service names, because one database can expose several services.
Ways to identify a database
Three forms identify the same target:
| Form | Example | Typical use |
|---|---|---|
| Easy Connect | //dbhost.example.com:1521/orclpdb1.example.com | SQLcl and quick tests |
| TNS alias | ORCLPDB | Shared tnsnames.ora entries |
| JDBC URL | jdbc:oracle:thin:@//dbhost.example.com:1521/orclpdb1.example.com | Java tools that ask for a URL |
SQL Developer and SQLcl: when to use which
SQL Developer is a graphical IDE. SQLcl is a command-line client that runs the same SQL and adds the CONNECT command, saved connections, and scripting. Use SQL Developer for browsing and editing. Use SQLcl for terminal work and scripts.
sql hr@//dbhost.example.com:1521/orclpdb1.example.comCreating a Basic connection in SQL Developer
- Open SQL Developer and click the plus icon next to Connections.
- Enter a connection name, the user name, and the password.
- Keep Connection Type set to Basic. Enter Hostname, Port, and Service name.
- Click Test. A status of Success confirms the parts are correct.
- Click Connect.
Exercise
The listener is running on port 1521, but a connection that uses service name ORCLPDB1 fails with ORA-12514. Which part is wrong?
Show answer
The service name. ORA-12514 means the listener does not know the requested service, so check the service name against the listener's registered services.