Sub topic 6
Connecting to Autonomous Database: Database Actions, TLS, and Wallets
This chapter assumes that you have an Oracle Cloud account, an Always Free Autonomous Database, and its ADMIN password. You should also know basic SQL and be comfortable using a browser and a terminal. The goal is to connect in two ways: through Database Actions in a browser and through a local Oracle client using TLS and a wallet.
Choose a connection method
Autonomous Database is a managed database. Oracle protects its network endpoint with encrypted connections, so a plain unencrypted database connection is not the normal setup.
| Method | Best for | What you need |
|---|---|---|
| Database Actions | Running SQL quickly in a browser | Browser and OCI access |
| Wallet connection | SQL*Plus, SQLcl, or applications | Wallet zip file and Oracle client |
| TLS connection | Clients that support secure TLS directly | TLS-capable driver and connection details |
Database Actions is the simplest option for learning SQL. A wallet is more useful when you want to run scripts locally or connect an application.
Open SQL in Database Actions
- Sign in to the Oracle Cloud Infrastructure console.
- Open the Autonomous Database details page.
- Select Database Actions, then select SQL.
- Sign in with a database user, such as
ADMIN. - Open a SQL worksheet and run a query.
Database Actions is a web application hosted by Oracle. Your browser uses HTTPS to reach it, and Database Actions connects to the database using Oracle-managed connection settings. You do not download or configure a wallet for this path.
Try a query that identifies the current database and user:
SELECT
sys_context('USERENV', 'DB_NAME') AS database_name,
sys_context('USERENV', 'SERVICE_NAME') AS service_name,
sys_context('USERENV', 'SESSION_USER') AS session_user
FROM dual;The SYS_CONTEXT function returns information about the current session. The SESSION_USER value tells you which database account is running the query.
Connect with a wallet
A wallet is a collection of Oracle client files. It normally contains certificates, network configuration, and service aliases. A service alias is a short name that represents a complete secure connection description.
To download a wallet, open the Autonomous Database details page and select DB Connection. Choose Download Wallet, enter a wallet password, and save the zip file. The wallet password protects the downloaded files. It is separate from the database user's password.
Extract the wallet into a private directory:
mkdir -p "$HOME/adb-wallet"
unzip Wallet_MYDB.zip -d "$HOME/adb-wallet"
export TNS_ADMIN="$HOME/adb-wallet"Replace Wallet_MYDB.zip with the file you downloaded. TNS_ADMIN tells Oracle client tools where to find tnsnames.ora and sqlnet.ora. These files are part of the wallet package.
List the service aliases in the wallet:
grep -E '^[A-Za-z0-9_.-]+[[:space:]]*=' \
"$TNS_ADMIN/tnsnames.ora"The output contains aliases for services with different workload and performance characteristics. Use the exact alias shown in your file. Then connect with SQL*Plus:
sqlplus "admin@mydb_high"Replace mydb_high with an alias from tnsnames.ora. SQL*Plus prompts for the ADMIN password. Do not put the password in the command line or in a script that you plan to share.
A wallet connection commonly uses mutual TLS, abbreviated mTLS. TLS encrypts the connection and verifies the server. Mutual TLS also lets the server verify client-side credentials from the wallet. The Oracle client reads the wallet files through TNS_ADMIN.
TLS without a wallet
Some current Oracle drivers support a TLS connection without an mTLS wallet. In this model, the driver uses a secure tcps connection and validates the Autonomous Database server certificate. The exact connection string depends on the driver and the connection details supplied by the OCI console.
Use the TLS connection string from the database's DB Connection page rather than guessing a service name. The driver must support TLS, certificate validation, and the authentication method required by Autonomous Database.
Never disable certificate validation to make a failed connection work. A setting that accepts any certificate removes the protection that TLS provides.
Troubleshoot connection failures
ORA-12154usually means that the client cannot find the service alias. CheckTNS_ADMIN, confirm thattnsnames.oraexists there, and copy the alias exactly.ORA-28759often means that the wallet files cannot be opened. Check the directory permissions and confirm thatTNS_ADMINpoints to the extracted wallet directory.- A timeout can mean that the database is stopped, the network is restricted, or a firewall blocks outbound access. Check the database state and the client network.
- Database Actions may be unavailable when the database is still starting or when your OCI user lacks permission to open it.
- A password error is different from a TLS error. First confirm the database username and password, then investigate wallet or network settings.
Exercise
You downloaded a wallet, set TNS_ADMIN, and SQL*Plus reports ORA-12154. What should you check first?
Show answer
Check that TNS_ADMIN points to the directory containing tnsnames.ora, then use an alias copied exactly from that file.