Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
18.5 An Interactive Query Viewer
495
Listing 18.15 DBResultsTableModel.java 
package coreservlets;
import javax.swing.table.*;
/** Simple class that tells a JTable how to extract
 *  relevant data from a DBResults object (which is
 *  used to store the results from a database query).
*/
public class DBResultsTableModel extends AbstractTableModel {
  private DBResults results;
  public DBResultsTableModel(DBResults results) {
    this.results = results;
  }
  public int getRowCount() {
    return(results.getRowCount());
  }
  public int getColumnCount() {
    return(results.getColumnCount());
  }
  public String getColumnName(int column) {
    return(results.getColumnNames()[column]);
  }
  public Object getValueAt(int row, int column) {
    return(results.getRow(row)[column]);
  }
}
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




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

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