一次添加一条数据;很简单,一个真实需求:一次添加140000行数据,就不是那么简单了;注意此时Hibernate 已经效率很低了。还是最原始的操作:
Connection con = null;
try {
con = this.getCommonDAOHibImpl().getConnection();
con.setAutoCommit(false);
PreparedStatement pstm = null;
String sql = "insert 表名" +
"(列1,列2,.......) " +
"values( ?, ?, ?, ?, ? , ?, ?, ?, ?, ?,?,?)";
pstm = con.prepareStatement(sql);
//执行保存到数据库
for(int i=0; i<msg......
阅读全文