Use tnsnames.ora in Oracle SQL Developer
Leveraging tnsnames.ora in Oracle SQL Developer

Learn how to configure and utilize your tnsnames.ora file within Oracle SQL Developer for streamlined database connections, avoiding manual entry of connection details.
Oracle SQL Developer is a powerful, free graphical tool for database development and administration. While it offers various ways to connect to an Oracle database, using a tnsnames.ora
file is often the most convenient and recommended method, especially in corporate environments. This file centralizes your database connection definitions, making it easier to manage multiple connections and ensuring consistency across different tools and users. This article will guide you through the process of configuring SQL Developer to recognize and use your tnsnames.ora
file.
Understanding tnsnames.ora
The tnsnames.ora
file is a configuration file used by Oracle Net Services to resolve connection identifiers (TNS aliases) to network addresses and service names. Essentially, it acts as a phone book for your Oracle databases. Instead of remembering complex hostnames, port numbers, and service names for each database, you can simply refer to them by a short, memorable alias defined in this file. This file is typically located in the network/admin
subdirectory of your Oracle Client or Oracle Database installation.
ORCL_DEV =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dev-db-server)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl_dev_service)
)
)
PROD_DB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = prod-db-server)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod_service)
)
)
Example content of a tnsnames.ora file
Configuring SQL Developer to Use tnsnames.ora
Oracle SQL Developer needs to know where to find your tnsnames.ora
file. This is done through its preferences. Once configured, SQL Developer will automatically populate the 'Network Alias' dropdown in the new connection dialog with all the aliases defined in your tnsnames.ora
file.
flowchart TD A[Start SQL Developer] --> B["Go to Tools > Preferences..."] B --> C["Navigate to Database > Advanced"] C --> D["Locate 'Tnsnames Directory' field"] D --> E["Browse and select the directory containing tnsnames.ora"] E --> F[Click OK] F --> G["Restart SQL Developer (if aliases don't appear)"] G --> H[Create New Connection] H --> I["Select 'TNS' Connection Type"] I --> J["Choose alias from 'Network Alias' dropdown"] J --> K[Connect!]
Workflow for configuring tnsnames.ora in SQL Developer
1. Open Preferences
Launch Oracle SQL Developer. Go to Tools
in the top menu bar, then select Preferences...
.
2. Navigate to Database Advanced Settings
In the Preferences dialog, expand Database
in the left-hand tree, then select Advanced
.
3. Specify Tnsnames Directory
On the right panel, locate the field labeled Tnsnames Directory
. Click the Browse...
button next to it. Navigate to the directory where your tnsnames.ora
file is located (e.g., C:\app\your_user\product\19.0.0\client_1\network\admin
or /opt/oracle/instantclient_19_3/network/admin
). Select the folder and click Select
or Open
.
4. Apply Changes and Restart
Click OK
to close the Preferences dialog. If your TNS aliases don't immediately appear when creating a new connection, close and restart SQL Developer to ensure the changes are fully applied.
5. Create a New Connection using TNS
Click the green plus icon (New Connection) or go to File > New > Database Connection
. In the 'New / Select Database Connection' dialog, choose the Connection Type
dropdown and select TNS
. You should now see your TNS aliases populated in the Network Alias
dropdown. Select the desired alias, enter your username and password, and click Connect
.
network/admin
directory of the client you intend to use. This ensures consistency and avoids potential connection issues.Troubleshooting Common Issues
Sometimes, even after configuring the tnsnames.ora
directory, you might encounter issues. Here are a few common problems and their solutions:
tnsnames.ora
file itself is correctly formatted. Syntax errors in the file can prevent SQL Developer (and other Oracle tools) from parsing it correctly, leading to aliases not appearing or connection failures.- Aliases not appearing:
- Double-check the path specified in
Preferences > Database > Advanced > Tnsnames Directory
. Make sure it points directly to the folder containingtnsnames.ora
, not the file itself. - Restart SQL Developer after making changes to the preferences.
- Verify the
tnsnames.ora
file exists and is readable by your user account. - Check for syntax errors within the
tnsnames.ora
file. Even a single misplaced parenthesis can cause issues.
- Double-check the path specified in
- Connection failures (ORA-12154: TNS:could not resolve the connect identifier specified):
- This error typically means the TNS alias cannot be found or resolved. Ensure the alias you selected in SQL Developer exactly matches an entry in your
tnsnames.ora
file. - Confirm the
tnsnames.ora
file is in the correct directory and that SQL Developer is pointing to that directory. - Test the connection outside of SQL Developer using
tnsping <alias_name>
from a command prompt to verify the TNS entry is valid and reachable.
- This error typically means the TNS alias cannot be found or resolved. Ensure the alias you selected in SQL Developer exactly matches an entry in your
- Using an Instant Client:
- If you're using an Oracle Instant Client, create a
network/admin
subdirectory within your Instant Client installation directory and place yourtnsnames.ora
file there. Then point SQL Developer to thisnetwork/admin
directory.
- If you're using an Oracle Instant Client, create a