org.mycore.backend.sql
Class MCRSQLRowReader

java.lang.Object
  extended by org.mycore.backend.sql.MCRSQLRowReader

public class MCRSQLRowReader
extends Object

Instances of this class are used to read the rows of a result set when an SQL query is done using MCRSQLConnection. This is a wrapper around java.sql.ResultSet that provides some convenience methods.

Version:
$Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
Author:
Frank Lützenkirchen
See Also:
ResultSet, MCRSQLConnection.doQuery( String )

Field Summary
protected static Logger LOGGER
           
protected  ResultSet rs
          The wrapped JDBC result set
 
Constructor Summary
MCRSQLRowReader(ResultSet rs)
          Creates a new MCRSQLRowReader.
 
Method Summary
 void close()
           
 void finalize()
           
 GregorianCalendar getDate(int index)
           
 GregorianCalendar getDate(String columnName)
           
 int getInt(int index)
          Returns the value of a column in the current result rowa as an int.
 int getInt(String columnName)
          Returns the value of a column in the current result rowa as an int.
 long getLong(int index)
           
 long getLong(String columnName)
           
 String getString(int index)
          Returns the value of a column in the current result row as a String, or null.
 String getString(String columnName)
          Returns the value of a column in the current result row as a String, or null.
 boolean next()
          Points the cursor to the next result row, returning true if there is such a next row.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER

rs

protected ResultSet rs
The wrapped JDBC result set

Constructor Detail

MCRSQLRowReader

MCRSQLRowReader(ResultSet rs)
Creates a new MCRSQLRowReader. This constructor is called by MCRSQLConnection methods that execute an SQL query.

See Also:
MCRSQLConnection.doQuery( String )
Method Detail

next

public boolean next()
             throws MCRPersistenceException
Points the cursor to the next result row, returning true if there is such a next row.

Returns:
true, if there was a next row; false, if the end is reached
Throws:
MCRPersistenceException
See Also:
ResultSet.next()

getString

public String getString(int index)
                 throws MCRPersistenceException
Returns the value of a column in the current result row as a String, or null.

Parameters:
index - the number of the column in the result row
Returns:
the String value of a column in the current result row, or null
Throws:
MCRPersistenceException

getDate

public GregorianCalendar getDate(int index)
                          throws MCRPersistenceException
Throws:
MCRPersistenceException

getString

public String getString(String columnName)
                 throws MCRPersistenceException
Returns the value of a column in the current result row as a String, or null.

Parameters:
columnName - the name of the column in the result row
Returns:
the String value of a column in the current result row, or null
Throws:
MCRPersistenceException

getDate

public GregorianCalendar getDate(String columnName)
                          throws MCRPersistenceException
Throws:
MCRPersistenceException

getInt

public int getInt(int index)
           throws MCRPersistenceException
Returns the value of a column in the current result rowa as an int.

Parameters:
index - the number of the column in the result row
Returns:
the int value of a column in the current result row, or Integer.MIN_VALUE if the column was null
Throws:
MCRPersistenceException

getLong

public long getLong(int index)
             throws MCRPersistenceException
Throws:
MCRPersistenceException

getInt

public int getInt(String columnName)
           throws MCRPersistenceException
Returns the value of a column in the current result rowa as an int.

Parameters:
columnName - the name of the column in the result row
Returns:
the int value of a column in the current result row, or Integer.MIN_VALUE if the column was null
Throws:
MCRPersistenceException

getLong

public long getLong(String columnName)
             throws MCRPersistenceException
Throws:
MCRPersistenceException

close

public void close()

finalize

public void finalize()
              throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable