
This article explains how to connect to an Oracle Autonomous database using SQL developer, SQL plus or other tools.
When we create an Oracle ADB on OCI, we just can’t connect directly to the database even though the Network ACL is disabled. The reason is mTLS authentication is set to Required by default.
Let us see how to connect to the ADB using SQL developer first and then SQL plus.
If you have downloaded SQL developer for connecting to your database on cloud, it’s super easy to connect.
Mutual TLS (mTLS) is a 2-way handshake between a client and a server, and a more secure way of connection compared to TLS.
- atp01_high
- atp01_low
- atp01_medium
- atp01_tp
- atp01_tpurgent
[oracle@linux-8 db-sample-schemas-main]$ cd order_entry/ [oracle@linux-8 order_entry]$ sqlplus admin/xxxxx@'(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522) (host=adb.us-ashburn-1.oraclecloud.com))(connect_data=(service_name=g34efa58d1e9751_atp01_high.adb.oraclecloud.com)) (security=(ssl_server_dn_match=yes)))' SQL*Plus: Release 19.0.0.0.0 - Production on Wed Feb 7 03:56:14 2024 Version 19.20.0.0.0 Copyright (c) 1982, 2022, Oracle. All rights reserved. ERROR: ORA-12506: TNS:listener rejected connection based on service ACL filtering Enter user-name:
So where do I get the connection description information from?
[oracle@linux-8 db-sample-schemas-main]$ ls -lrt total 28 -rwxrwx---. 1 root vboxsf 21984 Jan 9 21:17 Wallet_ATP01.zip drwxrwx---. 1 root vboxsf 4096 Feb 7 04:00 db-sample-schemas-main [oracle@linux-8 db-sample-schemas-main]$ unzip Wallet_ATP01.zip -d ./Wallet_ATP01 Archive: Wallet_ATP01.zip inflating: ./Wallet_ATP01/ewallet.pem inflating: ./Wallet_ATP01/README inflating: ./Wallet_ATP01/cwallet.sso inflating: ./Wallet_ATP01/tnsnames.ora inflating: ./Wallet_ATP01/truststore.jks inflating: ./Wallet_ATP01/ojdbc.properties inflating: ./Wallet_ATP01/sqlnet.ora inflating: ./Wallet_ATP01/ewallet.p12 inflating: ./Wallet_ATP01/keystore.jks [oracle@linux-8 db-sample-schemas-main]$ cd Wallet_ATP01/ [oracle@linux-8 Wallet_ATP01]$ vi sqlnet.ora [oracle@linux-8 Wallet_ATP01]$ more sqlnet.ora WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="?/network/admin"))) SSL_SERVER_DN_MATCH=yes [oracle@linux-8 Wallet_ATP01]$ vi sqlnet.ora [oracle@linux-8 Wallet_ATP01]$ more sqlnet.ora WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="/media/sf_Oracle/software/db-sample-schemas-main/Wallet_ATP01"))) SSL_SERVER_DN_MATCH=yes [oracle@linux-8 Wallet_ATP01]$ export TNS_ADMIN=/media/sf_Oracle/software/db-sample-schemas-main/Wallet_ATP01 [oracle@linux-8 Wallet_ATP01]$ sqlplus admin/xxxxx@atp01_high SQL*Plus: Release 19.0.0.0.0 - Production on Sat Feb 10 05:02:32 2024 Version 19.20.0.0.0 Copyright (c) 1982, 2022, Oracle. All rights reserved. Last Successful login time: Sat Feb 10 2024 04:11:47 +05:30 Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.22.0.1.0 SQL> select instance_name from v$ instance; INSTANCE_NAME ---------------- feky1pod2 SQL>
I just used atp01_high as my connect identifier as they are already defined in the tnsnames.ora file thats bundled in the zip.
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY=”/media/sf_Oracle/software/db-sample-schemas-main/Wallet_ATP01″)))SSL_SERVER_DN_MATCH=yes
We can configure different type of ACLs such as with specific IPs, CIDR block, VCNs or VCN OCID and the combination of these can be used in real environments.
jdbc:oracle:thin:@<connection string for the service intended>
jdbc:oracle:thin:@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-ashburn-1.oraclecloud.com))(connect_data=(service_name=g34efa58d1e9750_atp01_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
[oracle@linux-8 admin]$ pwd /oracle/db/db19/network/admin [oracle@linux-8 admin]$ ls -lrt sqlnet.ora tnsnames.ora -rw-r-----. 1 oracle oinstall 1629 Feb 7 04:33 tnsnames.ora -rw-r--r--. 1 oracle oinstall 619 Feb 10 05:16 sqlnet.ora [oracle@linux-8 admin]$ rm sqlnet.ora [oracle@linux-8 admin]$ tail tnsnames.ora rmancat = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = linux-8.selvapc.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = rmancat.selvapc.com) ) ) atp = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-ashburn-1.oraclecloud.com))(connect_data=(service_name=g34efa58d1e9751_atp01_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes))) [oracle@linux-8 admin]$ [oracle@linux-8 admin]$ tnsping atp TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 13-FEB-2024 10:18:22 Copyright (c) 1997, 2023, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to contact (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-ashburn-1.oraclecloud.com))(connect_data=(service_name=g34efa58d1e9750_atp01_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes))) OK (380 msec) [oracle@linux-8 admin]$ [oracle@linux-8 admin]$ sqlplus admin/xxxxx@atp SQL*Plus: Release 19.0.0.0.0 - Production on Tue Feb 13 10:18:37 2024 Version 19.20.0.0.0 Copyright (c) 1982, 2022, Oracle. All rights reserved. Last Successful login time: Mon Feb 12 2024 11:49:25 +05:30 Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.22.0.1.0 SQL>
In the above demo, I just removed my tnsnames.ora file meaning we don’t pass any location for the wallet files which is confirmed by blank o/p for Used parameter files of the tnsping.
Connect to Autonomous Database Using Oracle Database Tools