You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2014/11/11 15:01:34 UTC

[jira] [Commented] (CSV-139) CSVPrinter.printRecord(ResultSet) with metadata

    [ https://issues.apache.org/jira/browse/CSV-139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14206435#comment-14206435 ] 

Gary Gregory commented on CSV-139:
----------------------------------

Since no one's chimed in here, here is what I did:

{code:java}
final ResultSet resultSet = stmt.executeQuery("select ID, NAME from TEST");
final CSVPrinter printer = CSVFormat.DEFAULT.withHeader(resultSet).print(sw);
printer.printRecords(resultSet);
{code}

Since we already support printing headers, all we needed is a convenient way to get the header labels out of the result set, hence the new method {{org.apache.commons.csv.CSVFormat.withHeader(ResultSet)}}. There is also a {{org.apache.commons.csv.CSVFormat.withHeader(ResultSetMetaData)}} if you already have that object around.

> CSVPrinter.printRecord(ResultSet) with metadata
> -----------------------------------------------
>
>                 Key: CSV-139
>                 URL: https://issues.apache.org/jira/browse/CSV-139
>             Project: Commons CSV
>          Issue Type: New Feature
>          Components: Printer
>            Reporter: Gary Gregory
>
> In http://markmail.org/message/hudxi2fk3wez2rjz E. Bourg suggests:
> {quote}
> Does CSVPrinter.printRecord(ResultSet) print a header line derived from the metadata? I would add a boolean parameter to control this.
> {quote}
> Option 1: 
> Is the column name or column label printed? The column label I think.
> Option 2:
> Add CSVPrinter.printRecord(ResultSet, boolean)
> Option 3:
> Reuse a CSVFormat field. Which one? skipHeaderRecord? Add a new field?
> Option 4:
> Print other metadata info as comments?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)