Java Synchronization Data

Source: Internet
Author: User

1  Public voidSync_data () {2 3Connection Ocd_query_erp =NULL;4Connection o_to_portal=NULL;5 6String form_form_ocd_configuration= "Select org_vdc from Ocd_test";//data from MySQL corresponding to the resource pool7String form_erp_ocd_sql= "Select Org_cid,vms,provider_vdc,org_vdc,cpu,ram,storage,storage_plus from OCD_Test";//get data from ERP8String portal_ocd_insert_sql= "Insert into Ocd_test (org_cid,vms,provider_vdc,org_vdc,cpu,ram,storage,storage_plus) VALUES (?,?,?,?,?,?,?,?) ";9String portal_ocd_update_sql= "Update ocd_test set Org_cid=?,vms=?,provider_vdc=?,cpu=?,ram=?,storage=?,storage_ Plus=? where org_vdc =? ";Ten          OneList ocdidlist =NewArrayList (); A  -PreparedStatement O_query_erp =NULL; -PreparedStatement O_UPDATE_OCD =NULL; thePreparedStatement O_INSERT_OCD =NULL; -  - //Defining Parameters -String org_cid= ""; +         intVms=0; -String provider_vdc= ""; +String org_vdc= ""; AString cpu= ""; atString ram= ""; -         intStorage=0; -         intStorage_plus; -  - //get to the corresponding database first -ocd_query_erp= This. getconnection (datasource_from[0].getdrv (), Datasource_from[0].geturi (), Datasource_from[0].getuid (), datasource_from[0].getpwd ()); inO_to_portal = This. getconnection (datasource_from[0].getdrv (), Datasource_from[0].geturi (), Datasource_from[0].getuid (), datasource_from[0].getpwd ()); -  to //Precompiled SQL statements +o_query_erp=ocd_query_erp.preparestatement (form_erp_ocd_sql); -O_update_ocd=to_portal.preparestatement (portal_ocd_update_sql); theO_insert_ocd=to_portal.preparestatement (portal_ocd_insert_sql); *      $Statement O_to_portal_ =to_portal.createstatement ();Panax NotoginsengResultSet ocd_configuration =O_to_portal_ - . ExecuteQuery (form_form_ocd_configuration); the              while(Ocd_configuration.next ()) { +String tmp = ocd_configuration.getstring (1); A Ocdidlist.add (TMP); the             } + ocd_configuration.close (); - o_to_portal_.close (); $  $  - //Loading Data -Rs_from =o_query_erp.executequery (); the             if(Rs_from! =NULL) { -                  while(Rs_from.next ()) {Wuyi                         //Select the                         //Org_cid,vms,provider_vdc,org_vdc,cpu,ram,storage,storage_plus -                         //From ocd_test WuOrg_cid = Ui18n.getunicode (rs_from.getstring (1), "GBK"); -VMS = Rs_from.getint (2); AboutPROVIDER_VDC = Ui18n.getunicode (rs_from.getstring (3), "GBK"); $ORG_VDC = Ui18n.getunicode (rs_from.getstring (4), "GBK"); -                     //ORG_VDC = rs_from.getstring (4), "GBK"); -System.out.println (Rs_from.getstring (4)); - System.out.println (ORG_VDC); ACPU = rs_from.getstring (5); +Ram = rs_from.getstring (6); theStorage = Rs_from.getint (7); -Storage_plus = Rs_from.getint (8); $  the                         if(!ocdidlist.contains (ORG_VDC)) { the         //INSERT INTO Ocd_test (org_cid,vms,provider_vdc,org_vdc,cpu,ram,storage,storage_plus) VALUES (?,?,?,?,?,?,?,?) "; theO_insert_ocd.setstring (1, org_cid); theO_insert_ocd.setint (2, VMS); -O_insert_ocd.setstring (3, PROVIDER_VDC); inO_insert_ocd.setstring (4, ORG_VDC); theO_insert_ocd.setstring (5, CPU); theO_insert_ocd.setstring (6, RAM); AboutO_insert_ocd.setint (7, storage); theO_insert_ocd.setint (8, storage_plus); the                          the                             intresult =o_insert_ocd.executeupdate (); + o_insert_ocd.clearparameters (); -Count_insert + =result; theLog.info (Count_insert + "INERT ocd_test:org_vdc=" + org_vdc + "ok!");Bayi}Else { the                              the     //update ocd_test set, org_cid=?,vms=?,provider_vdc=?,cpu=?,ram=?,storage=?,storage_plus=? where org_vdc =? "; -O_update_ocd.setstring (1, org_cid); -O_update_ocd.setint (2, VMS); theO_update_ocd.setstring (3, PROVIDER_VDC); theO_update_ocd.setstring (4, CPU); theO_update_ocd.setstring (5, RAM); theO_update_ocd.setint (6, storage); -O_update_ocd.setint (7, storage_plus); theO_update_ocd.setstring (8, ORG_VDC); the                               the System.out.println (o_update_ocd.tostring ());94Count_update + =o_update_ocd.executeupdate (); theLog.info ("UPDATE org_vdc=" + org_vdc + "ok!"); the                              the                         }98                 } About             } - 101 102 }103 104 

Java Synchronization Data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.