}
abstract Column[] getCols() throws SQLException;
- abstract Row getNext();
+ abstract Row getNext() throws SQLException;
// Returns the number of (data) rows that were output
public int printTable(PrintWriter pw) throws SQLException {
rowCount += pending;
}
+ if (rowCount > 0) {
+ writeDivider(pw, colWidths);
+ }
+
// TODO: Implement a String table for i18n
pw.println("" + rowCount + " row(s) returned.");
pw.flush();
// Examine and buffer up to rowBuf.length rows.
// Returns the number of actual rows that were buffered (zero if no more rows are available).
- RowBuffer bufferRows(int[] colWidths)
+ RowBuffer bufferRows(int[] colWidths) throws SQLException
{
RowBuffer rowBuf = new RowBuffer();
void writeHeader(PrintWriter pw, Column[] cols, int[] colWidths) {
writeDivider(pw, colWidths);
- for (int idx = 1; idx <= cols.length; ++idx) {
+ for (int idx = 0; idx < cols.length; ++idx) {
Column col = cols[idx];
pw.print("|" + centrePad(col.getLabel(), colWidths[idx]));
}
for (int rowIdx = 0; rowIdx < rowBuf.getPending(); ++rowIdx) {
Row row = rowBuf.getRow(rowIdx);
for (int colIdx = 0; colIdx < colWidths.length; ++colIdx) {
- String value = "" + row.getValue(colIdx);
+ String value = "" + row.getValue(colIdx + 1);
String padding = repChar(' ', colWidths[colIdx] - value.length());
pw.print("|" + value + padding);
}