Closeable
, Flushable
, AutoCloseable
, ICsvResultSetWriter
, ICsvWriter
public class CsvResultSetWriter extends AbstractCsvWriter implements ICsvResultSetWriter
ResultSet
to a column in CSV file using
the column names stored in ResultSetMetaData
Constructor | Description |
---|---|
CsvResultSetWriter(Writer writer,
CsvPreference preference) |
Constructs a new
CsvResultSetWriter with the supplied Writer and CSV preferences. |
Modifier and Type | Method | Description |
---|---|---|
void |
write(ResultSet resultSet) |
Writes a JDBC
ResultSet as a CSV file. |
void |
write(ResultSet resultSet,
CellProcessor[] writeProcessors) |
Writes a JDBC
ResultSet as a CSV file. |
close, flush, getLineNumber, getRowNumber, incrementRowAndLineNo, writeComment, writeHeader, writeRow, writeRow, writeRow
getLineNumber, getRowNumber, writeComment, writeHeader
public CsvResultSetWriter(Writer writer, CsvPreference preference)
CsvResultSetWriter
with the supplied Writer
and CSV preferences. Note that the
writer
will be wrapped in a BufferedWriter
before accessed.writer
- the writerpreference
- the CSV preferencesNullPointerException
- if writer or preference are nullpublic void write(ResultSet resultSet) throws SQLException, IOException
ResultSet
as a CSV file. Each column in CSV file corresponds to a column in
ResultSet
, column order is preserved. Column names in CSV file corresponds to column names stored in
ResultSetMetaData
. toString
will be called on each element prior to writing.write
in interface ICsvResultSetWriter
resultSet
- ResultSet containing the values to writeSQLException
- if a database access error occurs or this method is called on a closed result setIOException
- if an I/O error occurredpublic void write(ResultSet resultSet, CellProcessor[] writeProcessors) throws SQLException, IOException
ResultSet
as a CSV file. Each column in CSV file corresponds to a column in
ResultSet
, column order is preserved. Column names in CSV file corresponds to column names stored in
ResultSetMetaData
. toString
will be called on each (processed) element prior to writing.write
in interface ICsvResultSetWriter
resultSet
- ResultSet containing the values to writewriteProcessors
- Array of CellProcessors used to further process data before it is written (each element in the
processors array corresponds with a CSV column - the number of processors should match the number of
columns). A null
entry indicates no further processing is required (the value returned by
toString() will be written as the column value).SQLException
- if a database access error occurs or this method is called on a closed result setIOException
- if an I/O error occurredCopyright © 2007–2018 Super CSV. All rights reserved.