Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
18.3 Some JDBC Utilities
481
Listing 18.7 DBResults.java (continued)
public String getProductName() {
return(productName);
}
public String getProductVersion() {
return(productVersion);
}
public int getColumnCount() {
return(columnCount);
}
public String[] getColumnNames() {
return(columnNames);
}
public int getRowCount() {
return(queryResults.size());
}
public String[] getRow(int index) {
return((String[])queryResults.elementAt(index));
}
public void addRow(String[] row) {
queryResults.addElement(row);
}
/** Output the results as an HTML table, with
* the column names as headings and the rest of
* the results filling regular data cells.
*/
public String toHTMLTable(String headingColor) {
StringBuffer buffer =
new StringBuffer("\n");
if (headingColor != null) {
buffer.append("
"\">\n ");
} else {
buffer.append(" \n ");
}
for(int col=0; col
buffer.append("" + columnNames[col]);
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved
|