/** Package sqlObjects @author: Ismael H F Santos @version: 1.0 @see */ package sqlObjects; import java.sql.*; import java.util.*; public class Select { Hashtable Records[]; int columns = 0; int current = 0; int max = 0; Connection c; String sql; // Constructor Method public Select (Connection c, String sql) { int index = 0; // Assign passed arguments this.c = c; this.sql = sql; try { // Create Statement Object and Execute SQL Statement sqlStatement = this.c.createStatement(); ResultSet results = sqlStatement.executeQuery(this.sql); // Get the meta data ResultSetMetaData resultsMeta = results.getMetaData(); // Get the column count for the result set this.columns = resultsMeta.getColumnCount(); // Create the array of Hashtable objects Records = new Hashtable[this.columns]; // Loop through all records while (results.next()) { // Increment the index counter index++; // Perform a loop to add items for columns for (int i = 0;i max)) { return; } // Set current record position to specified row this.current = row; } // Get a data value for specified row and column public String getItem (int row, int column) { // Check for valid row if ((row < 1) || (row > max)) { return ""; } // Check for valid column if ((column < 1) || (column > this.columns)) { return ""; } // Return specified data value return (String)Records[column - 1].get(new Integer(row)); } // Return the record count for the object public int rowCount () { // Return the value contained in the max variable return this.max; } // Return the number of columns public int columnCount () { // Return the value in the columns variable return this.columns; } }