Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
480
Chapter 18 JDBC and Database Connection Pooling
Listing 18.7 DBResults.java
package coreservlets;
import java.sql.*;
import java.util.*;
/** Class to store completed results of a JDBC Query.
* Differs from a ResultSet in several ways:
*
* ResultSet doesn't necessarily have all the data;
* reconnection to database occurs as you ask for
* later rows.
* This class stores results as strings, in arrays.
* This class includes DatabaseMetaData (database product
* name and version) and ResultSetMetaData
* (the column names).
* This class has a toHTMLTable method that turns
* the results into a long string corresponding to
* an HTML table.
*
*/
public class DBResults {
private Connection connection;
private String productName;
private String productVersion;
private int columnCount;
private String[] columnNames;
private Vector queryResults;
String[] rowData;
public DBResults(Connection connection,
String productName,
String productVersion,
int columnCount,
String[] columnNames) {
this.connection = connection;
this.productName = productName;
this.productVersion = productVersion;
this.columnCount = columnCount;
this.columnNames = columnNames;
rowData = new String[columnCount];
queryResults = new Vector();
}
public Connection getConnection() {
return(connection);
}
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