executeBatch0批量插入数据,如下代
码:
conn = DBToolkit .getConnection0
Statement stmt =
conn . createStatementO j //连续添加多条 SQL
stmt . addBatch (" insert into testdb . book ( kind , name ) values ( java ', java in j
aciton )")
stmt . addBatc (" insert into testdb . book ( kind , name ) values ( c ',’ c in aciton )")//执行批量执行
stmt .executeBatch0)
传统拼接insert into table() values(),(),()这种方式实现批量插入
采用数据库持久化框架,比如hibernate,根据插入的记录数,设定每多少次循环执行一次commit *** 作
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)