org.teiid.script.io
Class ResultSetReader
java.lang.Object
java.io.Reader
org.teiid.script.io.StringLineReader
org.teiid.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
| Fields inherited from class java.io.Reader |
lock |
|
Method Summary |
void |
close()
|
int |
getRowCount()
|
protected java.lang.String |
nextLine()
Get the next line of results from the ResultSet. |
static java.lang.String |
prettyPrint(java.sql.SQLXML xml)
|
static java.lang.String |
resultSetMetaDataToString(java.sql.ResultSetMetaData metadata,
java.lang.String delimiter)
Get the first line from the result set. |
| 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 |
ResultSetReader
public ResultSetReader(java.sql.ResultSet in)
ResultSetReader
public ResultSetReader(java.sql.ResultSet in,
java.lang.String delimiter)
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 results 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
getRowCount
public int getRowCount()
resultSetMetaDataToString
public static java.lang.String resultSetMetaDataToString(java.sql.ResultSetMetaData metadata,
java.lang.String delimiter)
throws java.sql.SQLException
- Get the first line from the result set. This is the resultset metadata line where
we gather the column names and their types.
- Returns:
-
- Throws:
java.sql.SQLException
prettyPrint
public static java.lang.String prettyPrint(java.sql.SQLXML xml)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
Copyright © 2010. All Rights Reserved.