fix: report row count from bulk copy path

The bulk path printed no count, so the trailing " rows written" line had no
number and callers parsing stdout got nothing. Count rows in the BulkSource
adapter (one per getRowData) and print it, matching the INSERT path's
"<n> rows written" so the count is captured.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Paul Trowbridge 2026-06-18 07:39:56 -04:00
parent ce76e93a77
commit 7be85a2da1

View File

@ -322,8 +322,11 @@ public class jrunner {
options.setBatchSize(10000);
options.setBulkCopyTimeout(0);
bulkCopy.setBulkCopyOptions(options);
bulkCopy.writeToServer(new BulkSource(rs, cols, dtn, trim));
BulkSource src = new BulkSource(rs, cols, dtn, trim);
bulkCopy.writeToServer(src);
bulkCopy.close();
// print the count so the trailing " rows written" line is parseable
System.out.print(src.rowsWritten());
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
@ -518,6 +521,7 @@ public class jrunner {
private final boolean trim;
private final int[] jdbcType;
private final boolean[] asString;
private long rows = 0;
BulkSource(ResultSet rs, int cols, String[] dtn, boolean trim) throws SQLException {
this.rs = rs;
@ -596,7 +600,10 @@ public class jrunner {
catch (SQLException e) { throw new RuntimeException(e); }
}
public long rowsWritten() { return rows; }
public Object[] getRowData() throws SQLServerException {
rows++;
Object[] row = new Object[cols];
try {
for (int i = 1; i <= cols; i++) {