com.metamatrix.script.io
Class ResultSetReader

java.lang.Object
  extended by java.io.Reader
      extended by com.metamatrix.script.io.StringLineReader
          extended by com.metamatrix.script.io.ResultSetReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class ResultSetReader
extends StringLineReader

This object wraps/extends a SQL ResultSet object as Reader object. Once the ResultSet can read as reader then it can be persisted, printed or compared easily without lot of code hassle of walking it every time.

PS: remember this is a Reader not InputStream, so all the fields read going to be converted to strings before they returned.

Since:
4.3
Author:
Ramesh Reddy

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
ResultSetReader(java.sql.ResultSet in)
           
ResultSetReader(java.sql.ResultSet in, java.lang.String delimiter)
           
 
Method Summary
 void close()
           
protected  java.lang.String nextLine()
          Get the next line of restuls from the ResultSet.
 
Methods inherited from class com.metamatrix.script.io.StringLineReader
read
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultSetReader

public ResultSetReader(java.sql.ResultSet in)

ResultSetReader

public ResultSetReader(java.sql.ResultSet in,
                       java.lang.String delimiter)
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class StringLineReader
Throws:
java.io.IOException
Since:
4.3
See Also:
Reader.close()

nextLine

protected java.lang.String nextLine()
                             throws java.io.IOException
Get the next line of restuls from the ResultSet. The first line will be the metadata of the resultset and then followed by the result rows. Each row will be returned as one line.

Specified by:
nextLine in class StringLineReader
Returns:
next result line from result set.
Throws:
java.io.IOException


Copyright © 2009. All Rights Reserved.