description Under construction statement, the meaning of the following two parameters:
The first parameter specifies the type of ResultSet. The options are:
type_forward_only: Default type. Only forward access is allowed and is not affected by changes made to the database by other users.
type_scroll_insensitive: Allows you to move forward or backward through the list, even for specific positioning, such as moving to the fourth record in the list or moving backward two records from the current position. Will not be affected by changes made to the database by other users.
type_scroll_sensitive: Like Type_scroll_insensitive, allows positioning in records. This type is affected by changes made by other users. If a user deletes a record after executing the query, that record disappears from the Re sultset. Similarly, changes to the data values are reflected in the ResultSet.
The second parameter sets the concurrency of ResultSet, which determines whether ResultSet can be updated. The options are:
concur_read_only: This is the default value, specified cannot be updated
ResultSet concur_updatable: Specifies that the ResultSet can be updated
1 Public voidSave (list<item>itemList) {2 3 Try {4Connection conn =jdbcutils.getconnection ();5String sql = "INSERT into ' rbyair_trace '. ' Trace_info ' (' track_id ', ' member_id ', ' mid ', ' session_id ', ' user_ip ', ' Opsystem ') ', ' phone_m odel ', ' app_name ', ' app_version ', ' campain_id ', ' page_context ', ' web_version ', ' Source_channel ' ', ' start_from ', ' Banne r_index ', ' activity_id ', ' category_id ', ' list_index ', ' pin_id ', ' Target_pinid ', ' g roup_id ', ' share_target ', ' Share_us erid ', ' joinuser_id ', ' order_id ', ' goods_id ', ' pay_type ', ' Order_type ' , ' url ', ' phone_time ', ' Trace_time ') VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?)";6Conn.setautocommit (false);7PreparedStatement PS =Conn8 . preparestatement (SQL, resultset.type_scroll_sensitive,9 resultset.concur_read_only);Ten intCount = 0; One for(Item item:itemlist) { A if(Item.gettrackid () = =NULL) { -Logger.error ("This data does not have a buy point id" +item.tostring ()); - Continue; the } -Ps.setstring (1, Item.gettrackid ()); -Ps.setint (2, Item.getmemberid ()); -Ps.setstring (3, Item.getmid ()); +Ps.setstring (4, Item.getsessionid ()); -Ps.setstring (5, Item.getuserip ()); +Ps.setstring (6, Item.getopsystem ()); APs.setstring (7, Item.getphonemodel ()); atPs.setstring (8, Item.getappname ()); -Ps.setstring (9, Item.getappversion ()); -Ps.setstring (10, Item.getcampainid ()); -Ps.setstring (11, Item.getpagecontext ()); -Ps.setstring (12, Item.getwebversion ()); -Ps.setstring (13, Item.getsourcechannel ()); inPs.setstring (14, Item.getstartfrom ()); -Ps.setint (15, Item.getbannerindex ()); toPs.setint (16, Item.getactivityid ()); +Ps.setint (17, Item.getcategoryid ()); -Ps.setint (18, Item.getlistindex ()); thePs.setint (19, Item.getpinid ()); *Ps.setint (20, Item.gettargetpinid ()); $Ps.setint (21, Item.getgroupid ());Panax NotoginsengPs.setint (22, Item.getsharetarget ()); -Ps.setint (23, Item.getshareuserid ()); thePs.setint (24, Item.getjoinuserid ()); +Ps.setlong (25, Item.getorderid ()); APs.setlong (26, Item.getgoodsid ()); thePs.setint (27, Item.getpaytype ()); +Ps.setint (28, Item.getordertype ()); -Ps.setstring (29, Item.geturl ()); $Ps.settimestamp (30, Item.getphonetime ()); $Ps.settimestamp (31, Item.gettracetime ()); - - Ps.addbatch (); thecount++; - if(count% 10000 = = 0) {Wuyi //1W One submission the Ps.executebatch (); - conn.commit (); WuCount = 0; - } About } $ Ps.executebatch (); - conn.commit (); - Ps.clearbatch (); -}Catch(SQLException e) { ALogger.error ("Insert data Error" +e.getmessage ()); +}
MySQL BULK Insert