") ;
try {
String driver = "oracle.jdbc.driver.OracleDriver";
Class.forName(driver) ;
// out.println("Driver loaded..
") ;
}
catch(Exception e) {
out.println("Failed to load driver "+ e.getMessage()) ;
Furniture.doFooter(out) ;
return;
}
String userPass;
try {
BufferedReader userPassIn = new BufferedReader(new FileReader("/home/sbj/servlet/WEB-INF/csoracleauth"));
userPass = userPassIn.readLine(); // Get Oracle username/password string from external file
}
catch (IOException e) {
out.println("Failed to read authorization file "+ e.getMessage()) ;
Furniture.doFooter(out) ;
return;
}
Connection con = null;
try {
String url = "jdbc:oracle:thin:"
+ userPass
+ "@oracle.cs.stir.ac.uk:1521:cs" ;
con = DriverManager.getConnection(url) ;
// out.println("Got connection...
");
}
catch(SQLException e) {
out.println("SQLException: " + e.getMessage()) ;
Furniture.doFooter(out) ;
return;
}
try {
Statement stmt = con.createStatement();
String query = "SELECT DISTINCT Season, Title FROM Panto" ;
out.println("The query is:
"
+ query + "
") ;
ResultSet rs = stmt.executeQuery(query);
int nrows = 0 ;
while (rs.next()) {
nrows++ ;
String year = rs.getString(1) ;
String panto = rs.getString(2) ;
out.println("In " + year + " the panto was " + panto + "
") ;
}
out.println("
(" + nrows + " pantomimes listed)
") ;
stmt.close() ;
}
catch(SQLException e) {
out.println("SQLException: " + e.getMessage()) ;
}
try {
con.close() ;
}
catch(SQLException e) {
out.println("SQLException: " + e.getMessage()) ;
}
Furniture.doFooter(out) ;
} // doGet
} // class