Sub topic 6
Connecting to Autonomous Database: Database Actions, TLS and Wallets
This chapter assumes you can already create an Always Free Autonomous Database in the Oracle Cloud console. It also assumes you know what a connection string and a service name are. You will learn three ways to reach the database: the browser tool Database Actions, a client over mutual TLS (mTLS) with a wallet, and a client over one-way TLS without a wallet.
Why connecting to Autonomous Database is different
A local container listens on a port you control, and you connect with a short Easy Connect string. An Autonomous Database sits behind Oracle-managed network endpoints, and every connection must be encrypted. There is no plain 1521 TCP listener you can use without TLS.
You have three ways in:
| Path | Needs a client install | Needs a wallet | Typical use |
|---|---|---|---|
| Database Actions (browser) | No | No | Quick SQL, user creation, data loading |
| mTLS with a wallet | Yes (SQLcl, SQL*Plus, a driver) | Yes | Default for scripts and applications |
| One-way TLS | Yes | No | Clients where a wallet is awkward |
Database Actions is the easiest way to start. The other two matter as soon as you connect from your own tools.
Database Actions
Database Actions is a web interface hosted by the database itself. It was formerly called SQL Developer Web. It provides a SQL worksheet, data loading, user management, and REST and JSON tools.
To open it:
- In the Oracle Cloud console, open your Autonomous Database's details page.
- Select Database actions, then SQL.
- Sign in as
ADMINwith the password you chose at creation.
The console signs you in automatically when you open the tool from the details page. You only type credentials if you open the Database Actions URL directly.
Run a first check in the worksheet:
SELECT sys_context('USERENV', 'CON_NAME') AS container_name,
sys_context('USERENV', 'SESSION_USER') AS session_user,
sys_context('USERENV', 'SERVICE_NAME') AS service_name
FROM dual;The service name tells you which consumer group Database Actions used. Section "Service names" below explains what that means.
Two points to keep in mind:
ADMINis a highly privileged account. Use it to create a development user (covered in a later chapter), then work as that user.- Database Actions is a convenient front end, not a full client. Long scripts, version control and automated tests are easier from SQLcl or a driver.
Two security models: mTLS and TLS
Autonomous Database offers two authentication modes on its public endpoint.
Mutual TLS (mTLS). Both sides present certificates. The server proves its identity to the client, and the client proves its identity to the server. The client's certificate and keys live in a wallet, which is a set of files you download. This is the default mode for new databases. It uses the tcps protocol on port 1522.
One-way TLS. Only the server presents a certificate. The client verifies it against the trust store of your operating system or runtime, so no wallet is needed. It uses tcps on port 1521. You must enable it explicitly on the database. In the console, edit the Mutual TLS (mTLS) authentication setting on the database details page and clear the requirement.
Security trade-off: with mTLS, a stolen password alone is not enough, because an attacker also needs the wallet. With one-way TLS, you usually restrict access another way, such as an access control list (ACL) of allowed IP addresses or a private endpoint. Availability of ACLs and the TLS-only setting for Always Free databases has changed between Oracle releases, so check the current options in your console before you plan around them.
Downloading and unpacking a wallet
On the database details page, select Database connection, then Download wallet. Choose an instance wallet for one database, or a regional wallet if you need every database in the region. For practice, use the instance wallet. The console asks you to set a wallet password. This password protects the keystore inside the wallet. It is not a database password.
The download is a ZIP file. Typical contents:
| File | Purpose |
|---|---|
| `tnsnames.ora` | Maps service names to full connection descriptors |
| `sqlnet.ora` | Client network settings, including the wallet location |
| `cwallet.sso` | Auto-login wallet (no password needed to read) |
| `ewallet.p12` | Password-protected PKCS#12 wallet |
| `ewallet.pem` | PEM version, used by some Python and Node.js setups |
| `keystore.jks`, `truststore.jks` | Java keystores for JDBC |
| `ojdbc.properties` | JDBC settings that point at the wallet |
Unzip it into a directory that only you can read:
mkdir -p ~/wallets/practice
unzip Wallet_PRACTICEDB.zip -d ~/wallets/practice
chmod 700 ~/wallets/practiceTreat the wallet like a credential. Do not commit it to a repository or share it in a chat. If it leaks, rotate it from the console (the Download wallet page lets you generate a new one and invalidate the old).
Service names
tnsnames.ora defines several aliases for one database. Each alias maps to a consumer group that sets priority and parallelism for your session:
| Alias suffix | Intended workload |
|---|---|
| `_tpurgent` | Highest-priority transaction processing |
| `_tp` | Typical transaction processing |
| `_high` | Reporting with high priority and parallelism |
| `_medium` | Reporting with medium priority |
| `_low` | Reporting with lowest priority, serial execution |
Always Free databases have a small CPU allocation. For practice, _low or _tp is a sensible choice. High parallelism does not help on a tiny database, and heavy parallel work may be limited.
Connecting with SQLcl or SQL*Plus
Both clients find the wallet through the TNS_ADMIN environment variable, which names the directory holding tnsnames.ora and sqlnet.ora.
First, check sqlnet.ora. The downloaded file usually contains this line:
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="?/network/admin")))The ? stands for the Oracle home. If your client has no Oracle home at that path, replace the directory with your actual wallet directory. A wrong path is a frequent cause of ORA-28759: failure to open file.
Then connect:
export TNS_ADMIN=~/wallets/practice
sql admin@practicedb_lowThe tool prompts for the password. Replace practicedb with the database name from your tnsnames.ora. SQL*Plus works the same way with sqlplus admin@practicedb_low.
SQLcl can also read the ZIP directly, which skips the unzip step and the sqlnet.ora edit:
sql -cloudconfig ~/Downloads/Wallet_PRACTICEDB.zip admin@practicedb_lowOnce connected, run the verification query from earlier. SESSION_USER should be ADMIN, and CON_NAME is the database's container name.
Connecting from Python
The python-oracledb driver runs in thin mode by default. Thin mode needs no Oracle Client libraries. For mTLS it needs the wallet files and the wallet password:
import getpass
import oracledb
wallet_dir = "/home/me/wallets/practice" # use your own path
connection = oracledb.connect(
user="admin",
password=getpass.getpass("Database password: "),
dsn="practicedb_low",
config_dir=wallet_dir,
wallet_location=wallet_dir,
wallet_password=getpass.getpass("Wallet password: "),
)
with connection.cursor() as cursor:
cursor.execute("SELECT sys_context('USERENV', 'SESSION_USER') FROM dual")
print(cursor.fetchone()[0])
connection.close()config_dir tells the driver where to find tnsnames.ora. wallet_location and wallet_password unlock the PEM wallet (ewallet.pem). With wallet_location omitted, the thin driver cannot complete the mTLS handshake.
Connecting with one-way TLS
After you enable one-way TLS, the Database connection dialog lets you choose TLS as the authentication type and shows connection strings for each service. A TLS connection string looks like this (host and service name shortened):
(description=(retry_count=20)(retry_delay=3)
(address=(protocol=tcps)(port=1521)(host=adb.eu-frankfurt-1.oraclecloud.com))
(connect_data=(service_name=abc123_practicedb_low.adb.oraclecloud.com))
(security=(ssl_server_dn_match=yes)))Copy the exact string from your console rather than typing it. You can pass it straight to a client without a wallet:
import getpass
import oracledb
dsn = (
"(description=(retry_count=20)(retry_delay=3)"
"(address=(protocol=tcps)(port=1521)(host=adb.eu-frankfurt-1.oraclecloud.com))"
"(connect_data=(service_name=abc123_practicedb_low.adb.oraclecloud.com))"
"(security=(ssl_server_dn_match=yes)))"
)
with oracledb.connect(user="admin",
password=getpass.getpass("Database password: "),
dsn=dsn) as connection:
print(connection.version)Keep ssl_server_dn_match=yes. It makes the client check that the certificate matches the host name, which protects you from a man-in-the-middle attack. Removing it to "make the error go away" disables that check.
Common connection errors
Detailed diagnosis comes in the troubleshooting chapter. These are the errors you will most likely meet first.
ORA-12154: TNS:could not resolve the connect identifier: The client cannot findtnsnames.ora, or the alias is misspelled. CheckTNS_ADMINand the alias.ORA-28759: failure to open file:sqlnet.orapoints at a wallet directory that does not exist. FixDIRECTORY.ORA-01017: invalid username/password: The database password is wrong. Do not confuse it with the wallet password.ORA-12170or a long hang: Your network blocks outbound port 1521 or 1522, or an ACL on the database does not include your IP address.ORA-12506: The listener rejected the connection because of the database's access control list.
Summary of the workflow
- Open Database Actions to confirm the database is available and to create a development user.
- Choose mTLS (default, wallet) or one-way TLS (no wallet, must be enabled).
- Download and protect the wallet, set
TNS_ADMIN, and fixsqlnet.oraif the wallet path is wrong. - Pick a service name suited to your workload, usually
_lowor_tpon Always Free. - Verify with a query on
sys_context.
Exercise
You downloaded a wallet and run sql admin@practicedb_low, but get ORA-12154: TNS:could not resolve the connect identifier. The same login works in Database Actions. Name two things to check, and say which port an mTLS connection uses.
Show answer
Check that TNS_ADMIN points at the directory containing tnsnames.ora (or use -cloudconfig with the ZIP), and that the alias practicedb_low matches an entry in that file exactly. The fact that Database Actions works shows the database is up, so the fault is in the client configuration. An mTLS connection uses tcps on port 1522.
Exercise
A teammate says: "To avoid wallet problems, I'll remove (security=(ssl_server_dn_match=yes)) from my TLS connection string." Why is this a bad idea, and what is the better fix for a certificate name error?
Show answer
That setting makes the client verify that the server certificate matches the host name, which prevents a man-in-the-middle attack. Removing it keeps encryption but drops the identity check. The better fix is to use the exact connection string and host name from the console, and make sure the client's trust store is current.