This example assumes a text file called dblist.txt exists in /u01/dba/java/source...
import java.io.*;
class filereadtest {
public static void main (String args []) throws IOException
{
String file_name = "/u01/dba/java/source/dblist.txt";
BufferedReader bufferedReader = new BufferedReader(new FileReader(file_name));
String line = "x";
while (line != null)
{
while ((line = bufferedReader.readLine()) != null)
{
System.out.println(line);
}
}
}
}
Scenario... Java code that runs SQL that should return a single row result set. If the SQL fails (due to something like a missing column) then run alternate SQL that uses a different query to populate the single row result set. If the SQL returns an empty set then force an exception so that the alternate SQL is run.