|
java代码里我有两个批量插入动作,连接池用的boncp,代码形式一样,如下:
con = DbConnectionManager.getConnection();
con.setAutoCommit(false);
pstmt = con.prepareStatement(INSERT_RECMNDINFO);
for (RecommendInfo recmndInfo : recmndInfos)
{
pstmt.setString(1, recmndInfo.getToJID());
pstmt.setString(2, recmndInfo.getRecommendedJID());
pstmt.setInt(3, recmndInfo.getStatus());
pstmt.setString(4, recmndInfo.getCreateTime());
pstmt.addBatch();
}
pstmt.executeBatch();
con.commit();
但产生的二进制日志文件一个产生的形式如下:
INSERT INTO T_Phonebook (username,contactphone,contactName,createTime,countryCode) VALUES ('10100150002','13200999991','friend1','001340177104460','0086'),('10100150002','13200999992','friend2','001340177104460','0086')....(后面省略)
另一个产生二进制文件如下:
BEGIN
/*!*/;
# at 12108
#120620 15:28:47 server id 1 end_log_pos 12346 Query thread_id=274 exec_time=0 error_code=0
SET TIMESTAMP=1340177327/*!*/;
INSERT INTO T_PendingRecommend(tojid,recommendedjid,status,createtime) values('10100999998@tanjianglong.hotalk.com','10100150002@t.hotalk.com',1,'001340177104461')
/*!*/;
# at 12346
#120620 15:28:47 server id 1 end_log_pos 12584 Query thread_id=274 exec_time=0 error_code=0
SET TIMESTAMP=1340177327/*!*/;
INSERT INTO T_PendingRecommend(tojid,recommendedjid,status,createtime) values('10100150002@t.hotalk.com','10100999999@tanjianglong.hotalk.com',2,'001340177104461')
/*!*/;
# at 12584
#120620 15:28:47 server id 1 end_log_pos 12822 Query thread_id=274 exec_time=0 error_code=0
SET TIMESTAMP=1340177327/*!*/;
INSERT INTO T_PendingRecommend(tojid,recommendedjid,status,createtime) values('10100999999@tanjianglong.hotalk.com','10100150002@t.hotalk.com',1,'001340177104461')
/*!*/;
.
.
.
.(省略中间的十几条)
# at 12822
#120620 15:28:47 server id 1 end_log_pos 12849 Xid = 25064835
COMMIT/*!*/;
为什么两种一样的批量插入方式产生的二进制文件不一致?后面这种拆成单条的执行语句怎么样才能让它变成一条执行语句?
|
|