java 事务批量删除,批量插入20w条数据,长事务有关问题

当前位置:我的异常网» Java Web开发 » 批量插入20w条数据,长事务有关问题

批量插入20w条数据,长事务有关问题

www.myexceptions.net  网友分享于:2013-01-24  浏览:57次

批量插入20w条数据,长事务问题

我把所有要插入的数据放在Vector中,然后用prepareStatement来设置各个参数,相关代码如下:

db   =   new   Database(dbURL,   false);

conn   =   db.getConn();

conn.setAutoCommit(false);

pstmt   =   conn.prepareStatement(preSql);

for   (int   j   =   0;   j   <   count;   ++j)

{

try   {

pstmt.clearBatch();

pstmt.clearParameters();

String[]   tmp   =   ((String[])setConf.elementAt(j));

for   (int   i   =   1;   i   <=   tmp.length;   ++i)   {

pstmt.setString(i,   tmp[i   -   1]);

}

pstmt.addBatch();

tmpRets   =   pstmt.executeBatch();

}   catch   (SQLException   e)   {

Loger.log.error( "some   operation   about   pstmt   throw   SQLException!\n "   +   e);

continue;

}

if   (tmpRets   !=   null)

文章评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值