Produced by Araxis Merge on 12/20/2017 5:56:09 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Genisis_2.0_v6_bld6.zip\Source Code\UI\DataOps\src\main\java\gov\va\genisis2\DatabaseTableCopy | DatabaseTableCopy.java | Thu Dec 14 19:57:07 2017 UTC |
| 2 | Genisis_2.0_v6_bld6.zip\Source Code\UI\DataOps\src\main\java\gov\va\genisis2\DatabaseTableCopy | DatabaseTableCopy.java | Wed Dec 20 21:16:18 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 722 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package go v.va.genis is2.Databa seTableCop y; | |
| 2 | ||
| 3 | import jav a.io.File; | |
| 4 | import jav a.math.Big Integer; | |
| 5 | import jav a.sql.Conn ection; | |
| 6 | import jav a.sql.Driv erManager; | |
| 7 | import jav a.sql.Prep aredStatem ent; | |
| 8 | import jav a.sql.Resu ltSet; | |
| 9 | import jav a.sql.SQLE xception; | |
| 10 | ||
| 11 | import org .apache.co mmons.dbut ils.DbUtil s; | |
| 12 | import org .apache.lo gging.log4 j.LogManag er; | |
| 13 | import org .apache.lo gging.log4 j.core.Log gerContext ; | |
| 14 | ||
| 15 | /** | |
| 16 | * This pr ogram copi es a table from a so urce datab ase to a t emporary d atabase to | |
| 17 | * have th e table's details lo gged into a manageme nt table. From the t emporary | |
| 18 | * databas e it copie s the tabl e to the d estination before va lidating t he table | |
| 19 | * on the destinatio n side thr ough a che cksum and a row-coun t. | |
| 20 | * | |
| 21 | * @author PII | |
| 22 | * | |
| 23 | * | |
| 24 | * This prog ram takes in the SQL server de tails in t he order n oted | |
| 25 | * below. | |
| 26 | * | |
| 27 | * SourceIP SourceDB S ourceSchem a Destinat ionIP Dest inationUse rname | |
| 28 | * Destinati onPassword Destinati onDB Desti nationSche ma Managem entIP | |
| 29 | * Managemen tUsername Management Password M anagementD atabase | |
| 30 | * Temporary Database M anagementS chema Tabl eName | |
| 31 | * | |
| 32 | * This prog ram prints out a mes sage eithe r stating the table was not | |
| 33 | * found, th ere was an error, or that it w as success ful. | |
| 34 | */ | |
| 35 | public cla ss Databas eTableCopy { | |
| 36 | pr ivate stat ic final o rg.apache. logging.lo g4j.Logger logger = LogManager .getLogger (DatabaseT ableCopy.c lass); | |
| 37 | ||
| 38 | pu blic stati c void mai n(String[] args) { | |
| 39 | if ( System.get Property(" config_hom e") != nul l) { | |
| 40 | File f ile = new File(Syste m.getPrope rty("confi g_home")); | |
| 41 | if (fi le.isFile( )) { | |
| 42 | LoggerCo ntext cont ext = (org .apache.lo gging.log4 j.core.Log gerContext ) LogManag er.getCont ext(false) ; | |
| 43 | // this will force a reconfi guration | |
| 44 | context. setConfigL ocation(fi le.toURI() ); | |
| 45 | } else { | |
| 46 | logger.e rror("Alte rnative lo gger prope rties not found. Usi ng default propertie s."); | |
| 47 | } | |
| 48 | } | |
| 49 | logg er.info("A rguments:" ); | |
| 50 | for (int i = 0 ; i < args .length; i ++) { | |
| 51 | logger .info(i + ". " + arg s[i]); | |
| 52 | } | |
| 53 | // c heck for c orrect amo unt of arg uments | |
| 54 | if ( args.lengt h != 15) { | |
| 55 | try { | |
| 56 | throw ne w IllegalA rgumentExc eption("Wr ong amount of argume nts.", nul l); | |
| 57 | } catc h (Illegal ArgumentEx ception e1 ) { | |
| 58 | System.o ut.println ("Wrong am ount of ar guments.") ; | |
| 59 | logger.e rror("Wron g amount o f argument s.", e1); | |
| 60 | return; | |
| 61 | } | |
| 62 | } | |
| 63 | Bool ean Source SchemaChec k = false; | |
| 64 | Bool ean Source TableCheck = false; | |
| 65 | Bool ean DestSc hemaCheck = false; | |
| 66 | Bool ean TableS chemaCheck = false; | |
| 67 | // i nitialize message to success | |
| 68 | Stri ngBuilder message = new String Builder("S uccessfull y copied t able: "); | |
| 69 | // f ill variab les with a rguments | |
| 70 | ||
| 71 | // s ource link ed server on managem ent | |
| 72 | Stri ng sourceI P = args[0 ].replaceA ll("\'", " ").trim(); | |
| 73 | Stri ng sourceD B = args[1 ].replaceA ll("\'", " ").trim(); | |
| 74 | Stri ng sourceS chema = ar gs[2].repl aceAll("\' ", "").tri m(); | |
| 75 | // d estination linked se rver on ma nagement a nd informa tion to be able to | |
| 76 | // c opy to des tination | |
| 77 | Stri ng destIP = args[3]. replaceAll ("\'", "") .trim(); | |
| 78 | Stri ng destUse rname = ar gs[4].repl aceAll("\' ", "").tri m(); | |
| 79 | Stri ng destPas sword = ar gs[5].repl aceAll("\' ", "").tri m(); | |
| 80 | Stri ng destDB = args[6]. replaceAll ("\'", "") .trim(); | |
| 81 | Stri ng destSch ema = args [7].replac eAll("\'", "").trim( ); | |
| 82 | // m anagement linked ser ver on des tination a nd informa tion to be able to | |
| 83 | // c opy to man agement | |
| 84 | Stri ng mgmtIP = args[8]. replaceAll ("\'", "") .trim(); | |
| 85 | Stri ng mgmtUse rname = ar gs[9].repl aceAll("\' ", "").tri m(); | |
| 86 | Stri ng mgmtPas sword = ar gs[10].rep laceAll("\ '", "").tr im(); | |
| 87 | Stri ng mgmtDB = args[11] .replaceAl l("\'", "" ).trim(); | |
| 88 | Stri ng tempDB = args[12] .replaceAl l("\'", "" ).trim(); | |
| 89 | Stri ng mgmtSch ema = args [13].repla ceAll("\'" , "").trim (); | |
| 90 | Stri ng mgmtTab le = "Mana gement_tab le"; | |
| 91 | // t able name to be copi ed | |
| 92 | Stri ng tableNa me = args[ 14].replac eAll("\'", "").trim( ); | |
| 93 | if ( logger.isI nfoEnabled ()) { | |
| 94 | logger .info("sou rceIP " + sourceIP); | |
| 95 | logger .info("sou rceDB " + sourceDB); | |
| 96 | logger .info("sou rceSchema " + source Schema); | |
| 97 | logger .info("des tIP " + de stIP); | |
| 98 | logger .info("des tUsername " + destUs ername); | |
| 99 | logger .info("des tPassword " + destPa ssword); | |
| 100 | logger .info("des tDB " + de stDB); | |
| 101 | logger .info("des tSchema " + destSche ma); | |
| 102 | logger .info("mgm tIP " + mg mtIP); | |
| 103 | logger .info("mgm tUsername " + mgmtUs ername); | |
| 104 | logger .info("mgm tPassword " + mgmtPa ssword); | |
| 105 | logger .info("mgm tDB " + mg mtDB); | |
| 106 | logger .info("tem pDB " + te mpDB); | |
| 107 | logger .info("mgm tSchema " + mgmtSche ma); | |
| 108 | logger .info("tab leName " + tableName ); | |
| 109 | } | |
| 110 | // i nitialize checksums | |
| 111 | BigI nteger pre Checksum; | |
| 112 | BigI nteger pos tChecksum; | |
| 113 | Conn ection des tCon = nul l; | |
| 114 | Conn ection mgm tCon = nul l; | |
| 115 | Prep aredStatem ent GetSou rceTables = null; | |
| 116 | Prep aredStatem ent GetSou rceSchemas = null; | |
| 117 | Prep aredStatem ent GetSou rceRowCoun t = null; | |
| 118 | Prep aredStatem ent GetDes tRowCount = null; | |
| 119 | Prep aredStatem ent GetMax ID = null; | |
| 120 | Prep aredStatem ent Insert Management Row = null ; | |
| 121 | Prep aredStatem ent Update SourceRowC ount = nul l; | |
| 122 | Prep aredStatem ent Update DestRowCou nt = null; | |
| 123 | Prep aredStatem ent GetSou rceChecksu m = null; | |
| 124 | Prep aredStatem ent GetDes tChecksum = null; | |
| 125 | Prep aredStatem ent Update SourceChec ksum = nul l; | |
| 126 | Prep aredStatem ent Update DestChecks um = null; | |
| 127 | Prep aredStatem ent mgmtCo py = null; | |
| 128 | Prep aredStatem ent Update StatusBefo reCopy = n ull; | |
| 129 | Prep aredStatem ent destCo py = null; | |
| 130 | Prep aredStatem ent tempCl ean = null ; | |
| 131 | Prep aredStatem ent Update StatusAfte rCopy = nu ll; | |
| 132 | Prep aredStatem ent Update CopyStatus = null; | |
| 133 | Prep aredStatem ent Corrup tedTable = null; | |
| 134 | Resu ltSet rs = null; | |
| 135 | try { | |
| 136 | logger .info("tab le copy pr ocess star ted"); | |
| 137 | String Builder gs t = new St ringBuilde r("EXEC sp _tables_ex @table_se rver = '" + sourceIP | |
| 138 | + "',@tabl e_catalog = '" + sou rceDB + "' ,@table_ty pe = 'TABL E'"); | |
| 139 | String Builder gs s = new St ringBuilde r("select * from [" + sourceIP + "].[" + sourceDB + "].sys.s chemas"); | |
| 140 | String Builder gs rc = new S tringBuild er("select count(*) from [" + sourceIP + "].[" + s ourceDB + "].[" | |
| 141 | + sourceSc hema + "]. [" + table Name + "]" ); | |
| 142 | String Builder gd rc = new S tringBuild er( | |
| 143 | "select co unt(*) fro m [" + des tDB + "].[ " + destSc hema + "]. [" + table Name + "]" ); | |
| 144 | String Builder gm id = new S tringBuild er( | |
| 145 | "SELECT MA X(ReqID) f rom [" + m gmtDB + "] .[" + mgmt Schema + " ].[" + mgm tTable + " ]"); | |
| 146 | String Builder im r = new St ringBuilde r("INSERT INTO [" + mgmtDB + " ].[" + mgm tSchema + "].[" + mg mtTable | |
| 147 | + "] (ReqI D, Databas eName, Sou rce_Schema , Destinat ion_Schema , Table_Na me, datean dtime) VAL UES ( ?, '" | |
| 148 | + sourceDB + "' , '" + sourceS chema + "' , '" + de stSchema + "' , '" + tableName | |
| 149 | + "', CURR ENT_TIMEST AMP )"); | |
| 150 | String Builder us rc = new S tringBuild er("UPDATE [" + mgmt DB + "].[" + mgmtSch ema + "].[ " + mgmtTa ble | |
| 151 | + "] SET r owcount_be fore_copy =? WHERE R eqID =?"); | |
| 152 | String Builder ud rc = new S tringBuild er("UPDATE [" + mgmt DB + "].[" + mgmtSch ema + "].[ " + mgmtTa ble | |
| 153 | + "] SET r owcount_af ter_copy = ? WHERE Re qID =?"); | |
| 154 | String Builder gs cs = new S tringBuild er("select SUM( CAST ( checksum (*) AS BIG INT )) fro m [" + sou rceIP | |
| 155 | + "].[" + sourceDB + "].[" + s ourceSchem a + "].[" + tableNam e + "]"); | |
| 156 | String Builder gd cs = new S tringBuild er("select SUM( CAST ( checksum (*) AS BIG INT )) fro m [" + des tDB + "].[ " | |
| 157 | + destSche ma + "].[" + tableNa me + "]"); | |
| 158 | String Builder us cs = new S tringBuild er("UPDATE [" + mgmt DB + "].[" + mgmtSch ema + "].[ " + mgmtTa ble | |
| 159 | + "] SET c hecksum_be fore_copy = ? WHERE ReqID = ?" ); | |
| 160 | String Builder ud cs = new S tringBuild er("UPDATE [" + mgmt DB + "].[" + mgmtSch ema + "].[ " + mgmtTa ble | |
| 161 | + "] SET c hecksum_af ter_copy = ? WHERE R eqID = ?") ; | |
| 162 | String Builder mc = new Str ingBuilder ("IF OBJEC T_ID(N'[" + tempDB + "].[" + m gmtSchema + "].[" + tableName | |
| 163 | + "]', N'U ') IS NOT NULL DROP TABLE [" + tempDB + "].[" + mg mtSchema + "].[" + t ableName | |
| 164 | + "] SELEC T * INTO [ " + tempDB + "].[" + mgmtSchem a + "].[" + tableNam e + "] FRO M [" + sou rceIP | |
| 165 | + "].[" + sourceDB + "].[" + s ourceSchem a + "].[" + tableNam e + "]"); | |
| 166 | String Builder us bc = new S tringBuild er("update [" + mgmt DB + "].[" + mgmtSch ema + "].[ " + mgmtTa ble | |
| 167 | + "] set s tatus_befo re_copy = 'Completed ' where Re qID = ?"); | |
| 168 | String Builder dc = new Str ingBuilder ("IF OBJEC T_ID(N'[" + destDB + "].[" + d estSchema + "].[" + tableName | |
| 169 | + "]', N'U ') IS NOT NULL DROP TABLE [" + destDB + "].[" + de stSchema + "].[" + t ableName | |
| 170 | + "] SELEC T * INTO [ " + destDB + "].[" + destSchem a + "].[" + tableNam e + "] FRO M [" + mgm tIP | |
| 171 | + "].[" + tempDB + " ].[" + mgm tSchema + "].[" + ta bleName + "]"); | |
| 172 | String Builder tc = new Str ingBuilder ("IF OBJEC T_ID(N'[" + tempDB + "].[" + m gmtSchema + "].[" + tableName | |
| 173 | + "]', N'U ') IS NOT NULL DROP TABLE [" + tempDB + "].[" + mg mtSchema + "].[" + t ableName + "]"); | |
| 174 | String Builder us ac = new S tringBuild er("UPDATE [" + mgmt DB + "].[" + mgmtSch ema + "].[ " + mgmtTa ble | |
| 175 | + "] SET s tatus_afte r_copy = ' Completed' where Req ID = ?"); | |
| 176 | String Builder uc s = new St ringBuilde r(" UPDATE [" + mgmt DB + "].[" + mgmtSch ema + "].[ " + mgmtTa ble | |
| 177 | + "] SET C opyStatus ='Copy Suc cessful' W HERE ReqID = ?"); | |
| 178 | String Builder ct = new Str ingBuilder (" UPDATE [" + mgmtI P + "].[" + mgmtDB + "].[" + m gmtSchema + "].[" | |
| 179 | + mgmtTabl e + "] SET CopyStatu s ='Copy C orrupted' WHERE ReqI D = ? DROP TABLE IF EXISTS [" + destDB | |
| 180 | + "].[" + destSchema + "].[" + tableName + "]"); | |
| 181 | // Con nect to se rver ... w orking on encryption | |
| 182 | destCo n = Driver Manager.ge tConnectio n("jdbc:jt ds:sqlserv er://" + d estIP + "/ " + destDB , destUser name, | |
| 183 | destPasswo rd); | |
| 184 | mgmtCo n = Driver Manager.ge tConnectio n("jdbc:jt ds:sqlserv er://" + m gmtIP + "/ " + mgmtDB , mgmtUser name, | |
| 185 | mgmtPasswo rd); | |
| 186 | // ini tialize pr epared sta tements fo r the curr ent table | |
| 187 | GetSou rceTables = mgmtCon. prepareSta tement(gst .toString( )); | |
| 188 | GetSou rceSchemas = mgmtCon .prepareSt atement(gs s.toString ()); | |
| 189 | GetSou rceRowCoun t = mgmtCo n.prepareS tatement(g src.toStri ng()); | |
| 190 | GetDes tRowCount = destCon. prepareSta tement(gdr c.toString ()); | |
| 191 | GetMax ID = mgmtC on.prepare Statement( gmid.toStr ing()); | |
| 192 | Insert Management Row = mgmt Con.prepar eStatement (imr.toStr ing()); | |
| 193 | Update SourceRowC ount = mgm tCon.prepa reStatemen t(usrc.toS tring()); | |
| 194 | Update DestRowCou nt = mgmtC on.prepare Statement( udrc.toStr ing()); | |
| 195 | GetSou rceChecksu m = mgmtCo n.prepareS tatement(g scs.toStri ng()); | |
| 196 | GetDes tChecksum = destCon. prepareSta tement(gdc s.toString ()); | |
| 197 | Update SourceChec ksum = mgm tCon.prepa reStatemen t(uscs.toS tring()); | |
| 198 | Update DestChecks um = mgmtC on.prepare Statement( udcs.toStr ing()); | |
| 199 | mgmtCo py = mgmtC on.prepare Statement( mc.toStrin g()); | |
| 200 | Update StatusBefo reCopy = m gmtCon.pre pareStatem ent(usbc.t oString()) ; | |
| 201 | destCo py = destC on.prepare Statement( dc.toStrin g()); | |
| 202 | tempCl ean = mgmt Con.prepar eStatement (tc.toStri ng()); | |
| 203 | Update StatusAfte rCopy = mg mtCon.prep areStateme nt(usac.to String()); | |
| 204 | Update CopyStatus = mgmtCon .prepareSt atement(uc s.toString ()); | |
| 205 | Corrup tedTable = destCon.p repareStat ement(ct.t oString()) ; | |
| 206 | ||
| 207 | // che ck for sch ema in sou rce databa se | |
| 208 | rs = G etSourceSc hemas.exec uteQuery() ; | |
| 209 | while (rs.next() ) { | |
| 210 | if (sour ceSchema.e quals(rs.g etString(1 ))) { | |
| 211 | SourceSche maCheck = true; | |
| 212 | } | |
| 213 | } | |
| 214 | if (!S ourceSchem aCheck) { | |
| 215 | System.o ut.println (sourceSch ema | |
| 216 | + " cannot b e found. P lease ente r in a val id Source schema nam e for the table to b e copied." ); | |
| 217 | logger.e rror(sourc eSchema | |
| 218 | + " cannot b e found. P lease ente r in a val id Source schema nam e for the table to b e copied." ); | |
| 219 | return; | |
| 220 | } | |
| 221 | DbUtil s.close(rs ); | |
| 222 | ||
| 223 | // che ck for tab le in sour ce databas e | |
| 224 | rs = G etSourceTa bles.execu teQuery(); | |
| 225 | while (rs.next() ) { | |
| 226 | if (tabl eName.equa lsIgnoreCa se(rs.getS tring("tab le_name")) ) { | |
| 227 | SourceTabl eCheck = t rue; | |
| 228 | } | |
| 229 | if (tabl eName.equa lsIgnoreCa se(rs.getS tring("tab le_name")) | |
| 230 | && sourceSch ema.equals (rs.getStr ing("table _schem"))) { | |
| 231 | TableSchem aCheck = t rue; | |
| 232 | } | |
| 233 | } | |
| 234 | if (!S ourceTable Check) { | |
| 235 | System.o ut.println ( | |
| 236 | ta bleName + " cannot b e found. P lease ente r in a val id table n ame for th e table to be copied ."); | |
| 237 | logger.e rror( | |
| 238 | ta bleName + " cannot b e found. P lease ente r in a val id table n ame for th e table to be copied ."); | |
| 239 | return; | |
| 240 | } else if (!Tabl eSchemaChe ck) { | |
| 241 | System.o ut.println (tableName + " does not exist for the Sc hema " + s ourceSchem a + "."); | |
| 242 | logger.e rror(table Name + " d oes not ex ist for th e Schema " + sourceS chema + ". "); | |
| 243 | return; | |
| 244 | } | |
| 245 | DbUtil s.close(rs ); | |
| 246 | ||
| 247 | // che ck for sch ema in des tination d atabase | |
| 248 | rs = d estCon.get MetaData() .getSchema s(); | |
| 249 | while (rs.next() ) { | |
| 250 | if (dest Schema.equ als(rs.get String("TA BLE_SCHEM" ))) { | |
| 251 | DestSchema Check = tr ue; | |
| 252 | } | |
| 253 | } | |
| 254 | if (!D estSchemaC heck) { | |
| 255 | System.o ut.println (destSchem a | |
| 256 | + " cannot b e found. P lease ente r in a val id Destina tion schem a name for the table to be cop ied."); | |
| 257 | logger.e rror(destS chema | |
| 258 | + " cannot b e found. P lease ente r in a val id Destina tion schem a name for the table to be cop ied."); | |
| 259 | return; | |
| 260 | } | |
| 261 | DbUtil s.close(rs ); | |
| 262 | ||
| 263 | // get the curre nt request ID from t able by ad ding one t o the | |
| 264 | // max | |
| 265 | rs = G etMaxID.ex ecuteQuery (); | |
| 266 | rs.nex t(); | |
| 267 | int ma xID = rs.g etInt(1) + 1; | |
| 268 | DbUtil s.close(rs ); | |
| 269 | // ins ert the ro w for the request in to the man agement ta ble | |
| 270 | Insert Management Row.setInt (1, maxID) ; | |
| 271 | Insert Management Row.execut eUpdate(); | |
| 272 | // cou nt the num ber of row s before c opying | |
| 273 | rs = G etSourceRo wCount.exe cuteQuery( ); | |
| 274 | rs.nex t(); | |
| 275 | int pr eRowCount = rs.getIn t(1); | |
| 276 | DbUtil s.close(rs ); | |
| 277 | Update SourceRowC ount.setIn t(1, preRo wCount); | |
| 278 | Update SourceRowC ount.setIn t(2, maxID ); | |
| 279 | Update SourceRowC ount.execu teUpdate() ; | |
| 280 | // cal culate che cksum befo re copying | |
| 281 | rs = G etSourceCh ecksum.exe cuteQuery( ); | |
| 282 | rs.nex t(); | |
| 283 | preChe cksum = Bi gInteger.v alueOf(rs. getLong(1) ); | |
| 284 | DbUtil s.close(rs ); | |
| 285 | Update SourceChec ksum.setOb ject(1, pr eChecksum) ; | |
| 286 | Update SourceChec ksum.setIn t(2, maxID ); | |
| 287 | Update SourceChec ksum.execu teUpdate() ; | |
| 288 | // cop y the tabl e into the database and update before co py | |
| 289 | mgmtCo py.execute Update(); | |
| 290 | // sta tus to suc cess | |
| 291 | Update StatusBefo reCopy.set Int(1, max ID); | |
| 292 | Update StatusBefo reCopy.exe cuteUpdate (); | |
| 293 | ||
| 294 | destCo py.execute Update(); | |
| 295 | tempCl ean.execut eUpdate(); | |
| 296 | // cal culate che cksum afte r copying | |
| 297 | rs = G etDestChec ksum.execu teQuery(); | |
| 298 | rs.nex t(); | |
| 299 | postCh ecksum = B igInteger. valueOf(rs .getLong(1 )); | |
| 300 | DbUtil s.close(rs ); | |
| 301 | Update DestChecks um.setObje ct(1, post Checksum); | |
| 302 | Update DestChecks um.setInt( 2, maxID); | |
| 303 | Update DestChecks um.execute Update(); | |
| 304 | // cou nt the num ber of row s after co pying | |
| 305 | rs = G etDestRowC ount.execu teQuery(); | |
| 306 | rs.nex t(); | |
| 307 | int po stRowCount = rs.getI nt(1); | |
| 308 | DbUtil s.close(rs ); | |
| 309 | Update StatusAfte rCopy.setI nt(1, maxI D); | |
| 310 | Update StatusAfte rCopy.exec uteUpdate( ); | |
| 311 | Update DestRowCou nt.setInt( 1, postRow Count); | |
| 312 | Update DestRowCou nt.setInt( 2, maxID); | |
| 313 | Update DestRowCou nt.execute Update(); | |
| 314 | // upd ate copy s tatus | |
| 315 | Update CopyStatus .setInt(1, maxID); | |
| 316 | Update CopyStatus .executeUp date(); | |
| 317 | // che ck if the row number s and chec ksums are equal if t hey | |
| 318 | // are n't, drop the corrup ted copy a nd update copy statu s to | |
| 319 | // cor rupted | |
| 320 | if (!( preChecksu m.subtract (postCheck sum)).equa ls(BigInte ger.ZERO) || preRowC ount - pos tRowCount != 0) { | |
| 321 | Corrupte dTable.set Int(1, max ID); | |
| 322 | Corrupte dTable.exe cuteUpdate (); | |
| 323 | throw ne w Exceptio n("corrupt ion on " + tableName , null); | |
| 324 | } | |
| 325 | // add the succe ssful tabl e to the m essage pri nted | |
| 326 | messag e.append(" '" + table Name + "' "); | |
| 327 | } | |
| 328 | // g eneric cat ch for oth er errors | |
| 329 | catc h (Excepti on e) { | |
| 330 | logger .error("An error occ urred duri ng transfe r. Please contact yo ur system administra tor.", e); | |
| 331 | messag e = new St ringBuilde r("An erro r occurred during tr ansfer. Pl ease conta ct your sy stem admin istrator." ); | |
| 332 | } fi nally { | |
| 333 | try { | |
| 334 | DbUtils. close(rs); | |
| 335 | DbUtils. close(GetD estRowCoun t); | |
| 336 | DbUtils. close(GetM axID); | |
| 337 | DbUtils. close(Inse rtManageme ntRow); | |
| 338 | DbUtils. close(Upda teSourceRo wCount); | |
| 339 | DbUtils. close(Upda teDestRowC ount); | |
| 340 | DbUtils. close(GetS ourceCheck sum); | |
| 341 | DbUtils. close(GetD estChecksu m); | |
| 342 | DbUtils. close(Upda teSourceCh ecksum); | |
| 343 | DbUtils. close(Upda teDestChec ksum); | |
| 344 | DbUtils. close(mgmt Copy); | |
| 345 | DbUtils. close(dest Copy); | |
| 346 | DbUtils. close(temp Clean); | |
| 347 | DbUtils. close(Upda teStatusAf terCopy); | |
| 348 | DbUtils. close(Upda teCopyStat us); | |
| 349 | DbUtils. close(Corr uptedTable ); | |
| 350 | DbUtils. close(dest Con); | |
| 351 | DbUtils. close(mgmt Con); | |
| 352 | } catc h (SQLExce ption e) { | |
| 353 | logger.e rror("An e rror occur red during closing. Please con tact your system adm inistrator . ", e); | |
| 354 | message = new Stri ngBuilder( | |
| 355 | "A n error oc curred dur ing closin g. Please contact yo ur system administra tor. "); | |
| 356 | } | |
| 357 | } | |
| 358 | logg er.info("O utput mess age: " + m essage.toS tring()); | |
| 359 | Syst em.out.pri ntln(messa ge.toStrin g()); | |
| 360 | } | |
| 361 | ||
| 362 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.