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