Sub topic 12
Connecting to a Cloud Database with a Wallet
Prerequisites
This chapter assumes that you understand host names, ports, service names, and database credentials. You also need access to an Oracle Cloud database, such as an Autonomous Database, a downloaded wallet ZIP file, and a database user.
A wallet is a package of connection files and security material. It usually contains:
tnsnames.ora, which defines service aliases.sqlnet.ora, which tells Oracle clients how to use the wallet.- Client certificates and keys for encrypted communication.
- Other files required by the cloud database service.
The wallet does not usually replace the database user's password. You still provide a user name and password unless your organization has configured another authentication method.
How the wallet connection works
A normal local connection can use a host, port, and service name directly. A wallet connection normally uses a TNS alias instead. The alias maps to a secure service descriptor and the wallet supplies the TLS configuration.
Keep the wallet directory private. Anyone who obtains its key material may be able to impersonate the client during network authentication, depending on the database configuration.
Download and prepare the wallet
In the cloud console, download the client credentials wallet for the database. Save the ZIP file outside source control. Extract it into a protected directory, such as:
/home/alice/oracle/wallets/MYDBDo not edit tnsnames.ora casually. The file may contain several aliases, such as MYDB_HIGH, MYDB_MEDIUM, and MYDB_LOW. These names can select different workload service levels.
The client must be able to read the extracted files. The directory does not need to be the current working directory.
Connect with SQLcl
Start SQLcl and point it at the wallet ZIP file or wallet configuration, depending on your SQLcl version. With the SQLcl SET CLOUDCONFIG command, you can provide the downloaded wallet:
SQL> set cloudconfig /home/alice/oracle/wallets/Wallet_MYDB.zip
SQL> connect admin@mydb_high
Password? ********
Connected.The alias mydb_high comes from the wallet's tnsnames.ora. Use the exact spelling and capitalization supported by your client configuration.
You can also inspect the extracted wallet directory and use its aliases through the Oracle network configuration. If SQLcl cannot resolve the alias, check that the wallet is configured before running CONNECT, and confirm that the alias exists in tnsnames.ora.
Connect with SQL Developer
In SQL Developer:
- Open the New / Select Database Connection dialog.
- Enter the database user name.
- Select TNS as the connection type.
- Set Configuration File or TNS Admin to the extracted wallet directory, as supported by your SQL Developer version.
- Select the wallet alias from the Service Name list.
- Enter the password and choose Test.
- Choose Connect after the test succeeds.
If the alias list is empty, SQL Developer is reading the wrong directory or cannot find tnsnames.ora. Point it at the directory containing that file, not merely at its parent directory or the original ZIP file.
Verify the target
After connecting, verify the session. This prevents accidentally using a similarly named service or a different database.
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;The service name should match the selected wallet alias's target. The server host confirms which database host accepted the session.
Troubleshoot wallet connections
ORA-12154usually means the client cannot resolve the TNS alias. Check the alias spelling and the directory containingtnsnames.ora.ORA-12514can mean the descriptor names a service that the listener does not provide. Download a current wallet and select a valid service alias.- TLS or certificate errors often indicate an incomplete extraction, an altered wallet file, an incompatible client, or an incorrect wallet directory.
- A password error such as
ORA-01017means the network connection worked, but the supplied credentials were rejected.
Exercise
SQLcl reads the wallet successfully, but connect admin@mydb_high returns ORA-12154. What should you check first?
Show answer
Check that the configured wallet or TNS Admin directory contains tnsnames.ora and that it defines the exact alias mydb_high.