this is our classic tnsnames.ora
test1=
(DESCRIPTION=
(CONNECT_TIMEOUT=4)
(TRANSPORT_CONNECT_TIMEOUT=3)
(ENABLE=BROKEN)
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=example1.example.com)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=example2.example.com)(PORT=1521))
)
(CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=EXAMPLE.EXAMPLE.DBS)
)
)
I use this SQLcl command:
sql -nohistory -noupdates -S $username/$password@$hostname:$port/$servicename @$filename
How to specifiy multiple hostnames? Not only one? It's some kind of active passive cluster (Exadata).
Edit after first answer:
I added in shell script (in this dir tnsnames.ora
):
TNS_ADMIN=/example/example
I call $sqlcl -nohistory -noupdates -S $username/$password@"MY-DB" @$filename
and get back the error:
./script.sh
USER = MY_USER
URL = jdbc:oracle:thin:@MY-DB
Error Message = IO Error: Unknown host specified
USER = MY_USER
URL = jdbc:oracle:thin:@MY-DB:1521/MY-DB
Error Message = IO Error: Invalid connection string format, a valid format is: "host:port:sid"