Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Created July 23, 2020 07:17
Show Gist options
  • Save saswata-dutta/e41781cc9f5c56612d2097dd8efb1e7c to your computer and use it in GitHub Desktop.
Save saswata-dutta/e41781cc9f5c56612d2097dd8efb1e7c to your computer and use it in GitHub Desktop.
List<List<String>> rows = ordered list of values per row.
connection con.setAutoCommit(false);
PreparedStatement prepStmt = con.prepareStatement(
"insert statement for 1 row with exact ? for place holders");
for row in rows:
for col_i in row.size:
prepStmt.setString(col_i, row[col_i])
prepStmt.addBatch()
int [] numInserts=prepStmt.executeBatch();
assert(numInsets and rows.size)
con.commit() (or rollback ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment