3?????????MySQL??????胁???100????????
???????????? ???????[ 2013/8/30 9:57:27 ] ????????
?????????写?????????MySQL??????胁??????????????????????????????锟�?use db_xk;
drop table if exists tb_test2;
create table tb_test2 (
id int primary key auto_increment??
subject varchar(50) not null??
description varchar(200) not null??
teacher_id int(10) zerofill not null??
student_id int(10) zerofill default null??
state boolean not null default false
);state boolean not null default false
);
?????????????????锟�?
package test;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import util.DBUtil;
public class TestDataBase2 {
public static void main(String[] args) {
Connection conn = DBUtil.getConnection();
String sql = "insert into tb_test2(subject?? description?? teacher_id?? student_id) values (??????????)";
try {
PreparedStatement prep = conn.prepareStatement(sql);
// ??????????????????????????????????????????
conn.setAutoCommit(false);
long start = System.currentTimeMillis();
for (int i = 0; i < 10; i++) {
long start2 = System.currentTimeMillis();
// ???????胁???10????????
for (int j = 0; j < 100000; j++) {
prep.setString(1?? "test2");
prep.setString(2?? "test3");
prep.setInt(3?? 1234562);
prep.setInt(4?? 12354545);
// ???????????????
prep.addBatch();
}
// ????????????
prep.executeBatch();
prep.clearBatch();
conn.commit();
long end2 = System.currentTimeMillis();
// ???????????????????????蔚????
System.out.print("inner"+i+": ");
System.out.println(end2 - start2);
}
long end = System.currentTimeMillis();
System.out.print("total: ");
System.out.println(end - start);
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(conn);
}
}
}
??????
???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11