62,614
社区成员
发帖
与我相关
我的任务
分享
try {
Session session = HibernateSessionFactory.getSession();
// tx = session.beginTransaction();
PreparedStatement stmt = session.connection().prepareStatement(
"insert into Channel (URL) values(?)");
stmt.setString(1,"http://www.arsenalsingapore.com/forum/index.php?board=5.1");
stmt.addBatch();
stmt.setString(1,"http://www.arsenalsingapore.com/forum/index.php?board=5.0");
stmt.addBatch();
stmt.setString(1,"http://www.arsenalsingapore.com/forum/index.php?board=5.2");
stmt.addBatch();
stmt.setString(1,"http://www.arsenalsingapore.com/forum/index.php?board=5.3");
stmt.addBatch();
stmt.executeBatch();
// tx.commit();
} catch (BatchUpdateException e) {
System.out.println("异常已经捕获");
// tx.rollback();
System.out.println(e.getUpdateCounts().length);
e.printStackTrace();
for (int i = 0; i < e.getUpdateCounts().length; i++) {
System.out.println(e.getUpdateCounts()[i] + "*********");
}
} catch (HibernateException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}