script for connecting database in loops

Hi experts.

I have different database and schema and their passwords in one file.
In Unix : I want to create the script that connect the sqlplus and execute the select query one by one schema with different database.
Ex: password File Format

[LEFT]databse schemaname password
DB1 name1 abcd
name2 abcd
DB2 name3 123
name 4456[/LEFT]

Any help will be highly appreciated.

#!/bin/sh

while read DB user pass
do
echo "
      WHENEVER SQLERROR EXIT 58
      connect user/pass@DB
      set head off pages 0 feedback off
      select sysdate from dual;
      exit" | sqlplus -s /nolog

done < File.txt

File.txt

DB1 name1 abcd
DB1 name2 abcd
DB2 name3 123
DB2 name 4456