#45 truncating resultsets

closed-fixed
Scott Conway
None
5
2010-02-24
2010-02-19
Anonymous
No

When using writeAll() for a resultset of 500 records, the file stopped about half way through record 491. When I scaled back to 450 records the file stopped around record 380. Reasons?

My code:
private static void createFiles() throws SQLException, IOException {
// TODO Auto-generated method stub
String tablename = "INITDATA";
int totalRecords = getRecordCount(tablename);
int chunk = 500;

int start = 0;
int end = 0;

for (int i = 0; i <= totalRecords; i += chunk) {
start = i;
end += chunk;

ResultSet data = getRecords(tablename, start, end);

CSVWriter writer = new CSVWriter(new FileWriter(
"d:\\sqlloader\\datawarehouse\\rebelmail\\data\\" + start
+ "-" + end + ".csv"));
writer.writeAll(data, true);
data.close();
}

}

Discussion

  • Scott Conway
    Scott Conway
    2010-02-21

    after the writeAll call writer.close()

    This will flush the write buffer and close the write stream.

    :)

     
  • Scott Conway
    Scott Conway
    2010-02-24

    call writer.close() after writeAll

     
  • Scott Conway
    Scott Conway
    2010-02-24

    • assigned_to: nobody --> sconway
    • status: open --> closed-fixed