Java's batch add data, and multiple fields are added at the same time. I don't know if you have encountered it. Today we will use a specific example of Java to add data, facing the Oracle database.
Front desk page:
<span style = "font-size: 14px;"> <body scroll = "no"> <div> <form name = "webform" method = "post"> <div> <div ID = "baseInfo" Onclick = "ActiveTabpaanel (1)" STYLE = "Margin-Right: 2px;"> Basic Information </DIV> <DIV ID = "SEMSINFO" Onclick = "Activetabanel (2)" "Margin-RIGHT: 2px "; > Package 1 </div> <div ID = "Changeinfo" OnClick = "ActiveTabanel (3)" STYLE = "Margin-Right: 2px;"> Pack 2 </DIV> <DIV ID = "FamilyInfo" onClick = "ActiveTabanel (4)" style = "margin-right: 2px;"> Page 3 </div> <div ID = "Changeinfo" onClick = "ActiveTabanel (5)" STYLE = "Margin-Right: 2px;"> Page 4 </div> <div ID = "Familyinfo" OnClick = "ActiveTabanel (6)" STYLE = "Margin-Right: 2px;"> Pack 5 </DIV> <DIV ID = "Familyinfo" onClick = " Activetabanel (7) "style =" margin-right: 2px; "> Page 6 </div> </div> </div> <div ID =" bankcarddiv "> <div> <div> information display <input ID = "addbank" type = "Button" value = "New line" onClick = "addnewrow ();" /> < /div> <div> <table id = "parttable" width = '100%' border = '0 'Cellspacing =' 1 'Cellpadding =' 0 'Class =' Content_list '> <TR> <th Class =' Content_table_number '> Serial Number </th> <TH> le_thnowarp '> Properties 1 </th> <TH Class = 'Content_table_thnowarp'> Properties 2 </th> <th class = 'Content_table_thnoWARP'> Properties 3 </th> <th class = 'Content_table_thnoWARP'> </this <TH> <TH> <TH> <TH> <TH Class = 'Content_table_thnowarp'> Properties 5 < /th> <TH class = 'Content_table_thnowarp'> Properties 6 </th> <TH class = 'Content_table_thnowarp'> Properties 7 </th> <TH> <CONTENT_TABLE_THNOWARP '> th> <th class = ' Content_table_thnowarp '> Properties 9 </th> <th class =' Content_table_thnowarp '> Operation </th> </tr> <c: if test = "$ {FNGTH (PERSONFAMILYINFOLIST)> 0}"> <C: foreach items = "$ {PersonFamilyInfolist}" var = "PersonFamilyInfolist" varstatus = "ST"> <!--> <TD> $ {st.Count} <input type = "hidden" natural = " Personfamilyinfolist [$ {st.count-1}]. Sguid "value =" $ {PersonFamilyInfolist.sguid} "/> <input type =" hidden "name =" PersonFamilyinfolist [$ {st.count-}]. s Personguid "value = "PersonFamilyInfolist.spersonguid}"/> <input type = "hidden" name = "personFamilyInfolist [$ {st.Count-1}]. Sunitguid" = "$ {person FAMILYINFOLIST.SUNITGUID} "> <input type = "hidden" name = "Personfamilyinfolist [$ {st.count-1}]. Isenable" value = "$ {PersonFamilyInfolist.isenable}"> </td> <!-Attribute 1-> <input ID = "SFAMILYNAME $ {St.Count-1}" Type = "Text" name = "PersonFamilyinfolist [$ {st.count-1}]. SFAMLYNAME" maxlength = "20" = "$ {porson Familyinfolist.sfamilyName} ">> </td> <!-Attribute 2-> <td> <input ID = "SFAMILYIDCADNO $ {st.count-}" Type = "Text" name = "PersonFamilyInfolist [$ {st.count-}] .SfamilyIdcardno "maxLength =" 20 "value =" $ {PersonFamilyinfolist.sfamilyidCardno} "> </td> <!-Attribute 3-> <select ID =" iFamilysex $ {ST.C {ST.C {ST.C OUNT-1} " name = "PersonFamilyInfolist [$ {st.count-1}]. iFamilysex> <zw: Basedictlist itemCode =" < %= constants.i_person_sex %> Onfamilyinfolist.iFamilysex} "> </zw: baseDictlist > </select> <font color = "red">*</font> </td> <!-Attribute 4-> <select id = "sfamilyrelation $ {st.count-}" namee = "PersonFamilyInfolist [$ {st.count-1}]. SFAMILYRELELELELATION> <zw: BasedicTList itemCode =" < %= constants.s_oldily_relation %> ErsonFamilyInfolist.sfamilyrelation} "> </zw: baseDictlist> </select> <font color = "red">*</font> </td> <!-Properties 5-> <input id = "sfamilyINSURANCEPLACE $ {str "Text" name = "Personfamilyinfolist [$ {st.count-1}]. SFAMILYINSURANCEPLACE" MAXLENGTH = "20" LACE} "> </td> <!-Attribute 6-> < td class = 'Content_table_td_centernowrap'> <input ID = "SFAMILYRESIDENCERCE $ {st.count-}" Type = "TEXT" natural st.Count-1}]. = "PersonFamilyInfolist.sfamilyResidePalce}"> </td> <!-Attribute 7-> <input id = "sfamilyphone $ {st.count 1} ErsonFamilyinfolist [$ {st.count-1}]. SFAMILYPHONE "maxLength =" 20 "value =" $ {PersonFamilyinfolist.sfamilyphone} "> </td> <!-Attribute 8-> <input id =" DDENTIFYSUCESSDATE $ {st.count 1} "Type =" Text "name =" PersonFamilyinfolist [$ {st.count-1}]. Infolist.DDENTIFYSUCESSDATE} "Onfocus =" WDATEPICKER () "NOTNULL = "True" vdisp = "The first insurance time" size = "18" maxlength = "18"/> <font color = "red">*</font> </td> <!-Attribute 9-> <td> <input ID = "ddentifylostdate $ {st.count -}" Type = "Text" name = "PersonFamilyInfolist [$ {st.Count -1}]. Personfamilyinfolist.dDentifylostdate} " Onfocus = "WDATEPICKER ()" NOTNULL = "TRUE" VDISP = "First Insurance Time" SIZE = "18" MAXLENGTH = "18"/> </TD> <TD Class = 'Content_TABLE_CENTERNOWRAP'> Cancel < /td> < /tr> </c: Foreach> </c: if> </table> </div> </div> </div> <div> <div> <table> <tr> <td align = "center" > <input id = "btnnextstep" type = "Button" value = "Previous" onClight = "" /> <input ID = "Btnadd" Type = "Button" Value = "OnClick =" SaVERUPDATE ) " / / > <input ID = "" Type = "Button" Value = "Complete" OnClick = "" /> <input ID = "Btnreturn" Type = "Button" Value = "Return" onClick = "" /> < /td> </tr> </table> </div> </div> </form> </div> </body> </span>
JavaScript function:
<span style = "font-family: kaiti_gb2312; font-siZe: 14px;"> <script type = "text/javascript"> $ (function () {loadcheck ()); loadcheck () {Var TRS = $ ('#PartTable Tr'). LENGTH; if (trs == 1) {addnewrow ();}} // Initial variable var num = 0; // Page count variable var row = 1; // Line increase counting variables Var Index = 2; // List List count variable variables function addnewrow () {var trunum = $ ('#parttable tr'). LENGTH; if (trunum> 1) {row = trunum; num = TRNUM -1; TMLTEXT = '<ter>'+'<td>'+row+'</td>'+'<<td>'+'<input ID = "SFAMILYNAME'+NUM+'" TEXT "name =" Personfamilyinfolist [' +NUM+']. SFAMILYNAME "maxLength =" 20 "> </td>'+'<td>'+'<input id =" sfamilyidno'+num+'"type =" text " Infolist ['+NUM+ '] .SfamilyIdcardno "maxlength =" 20 "> </td>'+'<<td>'+'<select id =" ifamilysex'+num+'"name =" PERSONFAMILYINFOLIST Ifamilysex "> ' +'<zw: Basedictlist itemCode = "2000" selectvalue = "PersonFamilyinfolist ['+NUM+']. </Zw: Basedictlist>' </SELECT> <fon t color = "red">*</font > </td> '+' <td> '+' <select id = "sfamilyrelation '+num+'" name = "personFamilyInfolist ['+num+']. Ictlist itemcode = "135 "SelectValue =" PersonFamilyinfolist [' +Num +']. SFAMILYRELATION> </ZW: Basedictlist> ' +' </Select> <font color = "red">*</font> </td> ' + '<TD > '+' <input ID = "SFAMILYINSURANCEPLEPLACEPLACE '+NUM+'" Type = "Text" name = "PersonFamilyInfolist ['+Num+']. th = "20"> </td> ' +' <<td> ' +'<input ID = "SFAMILYRESIDENCENCERCE'+NUM+'" Type = "Text" name = "PersonFamilyInfolist ['+Num+']. = "20"> </td> ' +' <TD> ' +' <input ID = "SFAMILYPHONE '+NUM+'" Type = "Text" name = "PersonFamilyinfolist ['+Num+']. SFAMILYPHONE" maxlength = "20"> </td> ' ' +' <input ID = "DDENTIFYSUCESSDATE '+NUM+'" Type = "Text" name = "PersonFamilyinfolist ['+Num+']. null = "true" vdisp = "The first insurance time" size = " 18 "maxLength =" 18 "/> <font color =" red ">*</font> </td> ' +' <<td> ' +' <input id =" ddentifylostdate ' +num +' "type =" text "name =" PersonFamilyinfolist ['+NUM+']. DDentifylostdate "Onfocus =" WDATEPICKER () "Notnull =" True "vdisp =" SIZE = "18" = " 18 "/> </td> ' +' <td> ' +' <a onclick = "DelinsuranceInfo (this);"> cancel </a> ' +' </td> ' +' </tr> '; $ ("#parttable"). Append (htmlText); num = num + 1; row + = 1;} // Delete the dynamic list function delinsuranceInfo (t) {if (row> 0) {row = row-1} Else {reTurn false;} $ (t ) .parent (). Parent (). Remove ();} // Save or modify the function saveorupdate () {$ .ajax ({urll: "Personfamilyinfo_addorupDatePersonfo_InClude_json.ac Tion ", Type:" Post ", Data: jquery (document. Forms [0]). Serializearray (), Success: Function (resobj) {// Judgment return value if (resobj.trim () == 'true') {ext.messageBox.alert ("prompt", "successful preservation" Function () {});} else if (resobj.trim () == 'update') {ext.messagebox.alert ("prompt", "update", function () {}); .Messagebox.alert ("Tips", "Save Fail");}});} </span> <span style = "font-family: kaiti_gb2312; font-size: 14px;"> </script> </</script> span>
Method of adding background:
<span style = "font-family: kaiti_gb2312; font-siZe: 14px;">/*** <p> description: Add multiple information in batches </p>* @param PersonFamilyinfolist entity list* @Return Boolean, true To add success, otherwise it will be added. ErsonFamilyInfolist) Throws Exception {Boolean Bool = False; If (PersonFamilyInfolist.size ()> 0 && PersonFamilyInfolist! = Null) {for (int i = 0; I <PersonfamilyInfolist.size (); I ++) {String PersonFamilyid = U u Uidhexgenrator.getuuid (); string sunitguid = "11111111"; String Spersonguid = "0000000"; if (PersonFamilyInfolist.get.get (i)! = Null) {PersonFamilyInfolist.get (I) .Setsguid (PersonFamilyid); PersonFamilyinfoli st.get (i) .setsunitguid (sunitguid); PersonfamilyInfolist.get (i) .setspersonguid (Speersonguid); PersonfamilyInfolist.get.get (i) .setisenable (0); PersonFamilyInfolist.get (i) .setdopictate (new date ())); // The current time of the system is effective. The failure time is placed as empty PersonFamilyInfolist .get (i) .setDDDENTIFYSUCESSDATE (new date ()); PersonFamilyInfolist.get (i) .setDddenFylostdate (null); TRY {string SguidString = PersonFamilyInfoserv ice.saveneedpk (Personfamilyinfolist.get (i). Tostring (); if (!!! "" .quals (SGUIDSTRING) && SguidString.length ()> 0) {Bool = TRUE;} else {System.out.println ("Supporting Relative Information Form"+I+"bar information storage failed! "); BOOL = false; Return Bool;}} Catch (Exception E) {e.printstacktrace ();}}} Return Bool;} </span>
Background update method:
<span style = "font-family: kaiti_gb2312; font-siZe: 14px;">/*** <p> description: Batch update information </p>* @param PersonFamilyinfolist ID staff ID * @Return Boolean, True represented the update, otherwise the update fails * @throws exception * @Author: Gaoying * @UPDATE: * @Date: 2015-7-20 */ Public Void (list <Personfa MilyInfo> PersonfamilyInfolist, String Personid) Throws Exception {// How many data are there? Familyinfolist.size (); if (PersonFamilyInfolist! = Null && PersonFamilyinfolist.size ()> 0) {// Check whether the information on the page is modified, and then update to the database for (int i = 0; i <num; i ++) {try {// Set a Boolean value. BOOL = TRUE; // What fields have changed if (! OldpersonfamilyInfolist.get.get (i) .getsFamilyName (). OOL = FALSE;} if (! Oldpersonfamilyinfolist. get (i) .getsFamilyidCardno (). Equals (PersonFamilyInfolist.get (i) .getsFamilyidCardno ()) {bool = false;} if (! OldpersonFamilyinfolist.get.get.get.get.get.get i) .getIFAMILYSEX (). Equals (Personfamilyinfolist.get.get (i ) .getIFAMILYSEX ())) {Bool = false;} if (! Oldpersonfamilyinfolist.get (i) .getsFamilyrelation (). lyrelation ()))) {bool = false;} if (!! OldpersonFamilyInfolist.get (i) .getsFamilyINSURANCEPLACE (). Equals (PersonFamilyInfolist.get (i) .getsFamilyINSURANCEPLERCE ()) {boool = FALSE; } if (! OldpersonFamilyInfolist.get (i) .GetsFamilyResidePalce (). (i) .getsFamilyResidePalce ())) {Bool = false;} if (! OldpersonFamilyInfolist.get (i) .GetsFamilyPhone (). ) .getsFamilyphone ())) {Bool = false;} System .out.println ("before changing time:+OldpersonFamilyInfolist.get.get (i) .getDDDENTIFYSUCESSDATE (). Gettime ()); Ist.get (i). getDDENTIFYSUCESSSDATE (). Gettime ()); if (OldpersonFamilyInfolist.get.get (i) .getDDDENTIFYSUCESSDATE (). Gettime ()! tDDENTIFYSUCESSDATE (). Gettime () {Bool = false;} if ( BOOL == FALSE) {// Prove that the field is changed // Before updating the data, copy one of the data that was not changed, add one into the database, and set the current time of the system to the failure time of the data. (); Beanutils.copyproperties (OldpersonFamilyInfolist.get (i), PersonFamilyinfo); System.out.println ("The main key of the data:" + PersonFamilyInfo.getsguid ()); Personfamilyinfo.setsguid (uuidhexgenrator.getuid ()); System .out.println ("Set the primary key:" + PersonfamilyInfo.getsguid ()); PersonFamilyInfo.setdOperatedate (new date ()); Enable (1); PersonFamilyInfo .setDDENTIFYLOSTDATE (new date ()); PersonFamilyInfoservice.save (PersonFamilyInfo); // Update the data, set the current time of the system to the effective time and operation time of the system. PersonFamilyInfolist.get (i) .setisenable (0); PersonfamilyInfolist.get (i) .setDDDENTIFYSUCESSDATE (new date ())); atedate (new date ())); Personfamilyinfolist.get (i) .setDDENTIFYLOSTDATE (Null); PersonFamilyInfoservice.merge (PersonFamilyInfolist.get (i));}} Catch (Exception E) {e.printstacktrace ();}} </span>
In this way, the examples of Java's multi -field and multiple data batch adds are completed. The main should be paid attention to the addition and update methods of the front desk page superimposed on the front desk page. Use it to receive it with LIST, and the cycle traversal is added. In addition, I want to talk about the following code:
Copy code code as follows: <span style = "font-family: kaiti_gb2312; font-size: 14px;"> $ (function () {
loadcheck ();
}); </span>
It is the abbreviation of the following code:
Copy code code as follows: <span style = "font-family: kaiti_gb2312; font-size: 14px;"> $ (document). READY (function () {)
loadcheck ();
}); </span>
In fact, this code and the following code mean:
Copy code code as follows: <span style = "font-family: kaiti_gb2312; font-size: 14px;"> Window.onload = Function () {{
loadcheck ();
} </span>
In this way, you do n’t need to call in the Online ONLOAD event, you only need to write in the JS program segment. Although the following code can be exchanged with the two above, they are different. The first is that the execution time is different. The $ (docume). READY is executed after downloading the page framework, and Window.onload must be carried out after all the page is loaded (including pictures download). Obviously the former's execution efficiency is higher than the latter. Then there is the difference in execution, $ (document). READY can repeat multiple, and each execution result is different; although Window.onload can execute multiple, only the last execution result is output, and multiple results cannot be completed. Output.
The above is all the contents of this article. I hope it will be helpful to everyone's learning.