Skip to content

Instantly share code, notes, and snippets.

@yuikns
Created August 14, 2014 06:10
Show Gist options
  • Save yuikns/d190eadde5334cebbcff to your computer and use it in GitHub Desktop.
Save yuikns/d190eadde5334cebbcff to your computer and use it in GitHub Desktop.
public void insertBatch(List<AcmAuthor2paper> objList) {
String sql = String.format("INSERT INTO %s.author2paper(id,aid,pid,position) VALUES (?,?,?,?)", dbName);
DBConnection conn = pool.getConnection();
PreparedStatement ps = null;
try {
conn.setAutoCommit(false);
ps = conn.prepareStatement(sql);
for (AcmAuthor2paper obj : objList) {
_constructPS(ps, obj);
ps.addBatch();
}
ps.executeBatch();
conn.setAutoCommit(true);
} catch (SQLException e) {
e.printStackTrace();
} finally {
ConnectionPool.close(conn, ps);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment