src/com/oa/db/Test.java

(完整代码) 838B

package com.oa.db;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class Test {
	/**
	 * 每隔100条做一个保存点
	 * 事物回滚的时候回到指定保存点
	 * SavePoint
	 * @param args
	 * @throws SQLException
	 */
	public static void main(String[] args) throws SQLException {
		long l1 = System.currentTimeMillis();
		Connection con = null;
		con = DB.getConnection();
		Statement stmt = con.createStatement();
		for(int i=0;i<=1000;i++) {
			String sql = "insert into t_organization values('"+i+"','+"+i+"+哈哈+','嘿嘿','"+i+"',null)";
			stmt.addBatch(sql);
			if(i%10==0) {
				stmt.executeBatch();
				stmt.clearBatch();
			}
		}
		long l2 = System.currentTimeMillis();
		System.out.println("此次插入用时-----"+(l2-l1)+"mms");
		stmt.close();
		con.close();
	}

}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。