Created
August 14, 2014 06:10
-
-
Save yuikns/d190eadde5334cebbcff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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