// of its assignee, in this case the String variable Output. // We simply get each “cell” and add a space to it, then append it onto // the Output variable. } // End for loop (end looping through the columns for a specific row ). Output+=”n”; // For each row that we fetch, we need to add a carriage return so that // the next fetched row starts on the next line. } // End while loop ( end fetching rows when no more rows are left ). stmt.close(); // Clean up, close the stmt, in effect, close the input-output query // connection streams, but stay connected to the data source. } catch( Exception e ) { e.printStackTrace(); Output=e.getMessage(); } // We have to catch any exceptions that were thrown while we were // querying or retrieving the data. Print the exception // to the console and return it so it can be shown to the user // in the applet. return Output; // Before exiting, return the result that we got. } Wrapping It Up The last part of the applet, shown in Listing 4.9, involves terminating the connection to the data source. This is done in the destroy method of the applet. We have to catch an exception, if one occurs, while the close method is called on the connection. Listing 4.9 Terminating the connection. public void destroy() { try {con.close();} catch( Exception e ) { e.printStackTrace(); System.out.println(e.getMessage()); } } // end destroy } // end applet The HTML File That Calls The Applet We need to call this applet from an HTML file, which is shown in Listing 4.10. We don t pass in any properties, but we could easily include a default data source URL and user name that the applet would read in before initializing the user interface, and then set the appropriate TextField to show these defaults. Note that we set the width and height carefully in the