be.six.reports.data
Class DatabaseResult

java.lang.Object
  extended by be.six.reports.data.DatabaseResult

public class DatabaseResult
extends java.lang.Object

An offline representation of the result of a SELECT statement. It tries to convert database types to the equivalent Java type. Watch out for results with more than 100k rows: the heap space needed will grow significantly. This could lead to heap space errors.

Author:
Joren Six

Field Summary
static DatabaseResult EMPTYRESULT
           
 
Constructor Summary
DatabaseResult(java.sql.ResultSetMetaData metaData)
          Initializes the database result.
 
Method Summary
 void addRow(java.sql.ResultSet rs)
          Adds a row to the DatabaseResult
 java.lang.String getColumName(int col)
           
 java.lang.Class<?> getColumnClass(int col)
           
 int getColumnCount()
           
 int getRowCount()
           
 java.lang.Object getValueAt(int row, int column)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTYRESULT

public static final DatabaseResult EMPTYRESULT
Constructor Detail

DatabaseResult

public DatabaseResult(java.sql.ResultSetMetaData metaData)
               throws java.sql.SQLException
Initializes the database result.

Parameters:
metaData - the meta data for this result. Contains information about the columns.
Throws:
java.sql.SQLException - when using the meta data goes awry.
Method Detail

addRow

public void addRow(java.sql.ResultSet rs)
            throws java.sql.SQLException
Adds a row to the DatabaseResult

Parameters:
rs - the ResultSet from a SELECT statement.
Throws:
java.sql.SQLException - when reading data goes awry.

getRowCount

public int getRowCount()
Returns:
the number of rows in the DatabaseResult

getColumnCount

public int getColumnCount()
Returns:
the number of columns in the databaseResult

getColumnClass

public java.lang.Class<?> getColumnClass(int col)
Parameters:
col - the column
Returns:
the class of the selected column

getColumName

public java.lang.String getColumName(int col)
Parameters:
col - the column
Returns:
the name of the column

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Parameters:
row - the row
column - the column
Returns:
the value at the selected position