I am new to shell scripting and have less or no idea on this. I have to read a db.properties file which has the database connection details i.e. to which db to connect. Then i have to establish a connection to that database and perform an operation to check the current time.
Below is my db.properties file :-
driverClassName=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@171.01.187.94:1532:DEV
userName=abc
password=abc
Below is my script to call the db.properties file :-
#!/bin/bash
file="./database.properties"
if [ -f "$file" ]
then
echo "$file found."
. $file
echo "User Id = " ${userName}
echo "user password = " ${password}
echo "url = " ${url}
sqlplus -S ${userName}/${password}@${url}
else
echo "$file not found."
fi
But i am getting the below error :-
ERROR: ORA-12154: TNS:could not resolve the connect identifier specified
Could anyone please help on the above issue ?
SQL*Plus. That's never going to work. You'd generally want to create an entry in yourtnsnames.orafile, assuming that you are using local naming, that points to this database. Assuming that TNS alias is named "dev", you'd thensqlplus user/password@devto connect to the database.