@Testpublic void Clockingin_img () throws EXCEPTION{DBJDBC IDB = DBMASTER.GETIDB ("JXT"); List<jxt_pay_info> pays=idb.getbeanlist ("SELECT top 100000 * from Jxt_pay_info", jxt_pay_info.class);// You can test it with IDB .... Big Data insertion method String sql = "INSERT into Jxt_pay_info1 (ID, card_id, Pay_money, Pay_time, Pay_date, pay_address, school_id, sour ce_id, Lasttime, Card_sn,paid_after) VALUES (?,?,?,?,?,?,?,?,?,?,?) "; Connection Connection = IDB. DbConnection; PreparedStatement PS = connection.preparestatement (SQL), final int batchsize = 1000;int count = 0;long Start=system.curren Ttimemillis (); System.err.println ("Start"); for (Jxt_pay_info pay:pays) {ps.setint (1, Pay.getid ()); Ps.setstring (2, pay.getcard_id ()); Ps.setfloat (3, Pay.getpay_money ()); Ps.setstring (4, Pay.getpay_time ()); Ps.setstring (5, Pay.getpay_date ()); Ps.setstring (6, pay.getpay_address ()); Ps.setstring (7, pay.getschool_id ()); Ps.setstring (8, pay.getsource_id ()); Ps.setstring (9, Pay.getlasttime ()); Ps.setint (10,PAY.GETCARD_SN ()); Ps.setstring (one, Pay.getpaid_after ()); Ps.addbatch (); }ps.executebatch (); Insert remaining recordsps.close (); Connection.close ();D BMASTER.CLOSEIDB (IDB); Long End=system.currenttimemillis ( ); System.err.println ("End" + (End-start));}}
Insert 1000:347 ms
Insert 1W Bar: 4086 ms
Insert 10W Bar: 47953 ms
Similarly, batch updates can also be used with this method, except that they are not inserted quickly,
Update 1000:90 seconds
Update 100:9 seconds
Java efficiently BULK INSERT SQL Server database