#!/bin/bash
# Set Oracle environment variables
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/19c/db_1
export ORACLE_SID=DBSPRD
export PATH=$ORACLE_HOME/bin:$PATH
# Log file
LOG_FILE=connection_test.log
# Function to test connection
test_connection() {
echo "Testing Oracle connection..."
start_time=$(date +%s.%N)
sqlplus -s / as sysdba <<EOF >> $LOG_FILE
WHENEVER SQLERROR EXIT SQL.SQLCODE
SELECT 'Connected to Oracle' FROM dual;
EXIT;
EOF
end_time=$(date +%s.%N)
duration=$(echo "$end_time - $start_time" | bc)
echo "Connection time: ${duration} seconds" >> $LOG_FILE
}
# Run the test multiple times
for i in {1..10}; do
test_connection
done
echo "Test completed. Check $LOG_FILE for details."