Produced by Araxis Merge on 6/20/2018 10:24:20 AM Central Daylight 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 | CCRS.zip\CCRS\Reports-Sprint_5.zip\Reports-Sprint_5-aa03f94869cda45ee08ca75641e61a7376f2c2a5\CCRSBaseHelper\src\main\java\gov\va\ccrs\helpers | DBUtil.java | Fri Mar 30 15:47:12 2018 UTC |
2 | CCRS.zip\CCRS\Reports-Sprint_5.zip\Reports-Sprint_5-aa03f94869cda45ee08ca75641e61a7376f2c2a5\CCRSBaseHelper\src\main\java\gov\va\ccrs\helpers | DBUtil.java | Tue Jun 19 17:17:19 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 272 |
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.ccrs. helpers; | |
2 | ||
3 | import jav a.io.FileW riter; | |
4 | import jav a.sql.Call ableStatem ent; | |
5 | import jav a.sql.Conn ection; | |
6 | import jav a.sql.Driv erManager; | |
7 | import jav a.sql.Resu ltSet; | |
8 | import jav a.sql.Resu ltSetMetaD ata; | |
9 | import jav a.text.Sim pleDateFor mat; | |
10 | import jav a.util.Dat e; | |
11 | import jav a.util.str eam.IntStr eam; | |
12 | ||
13 | import org .apache.lo g4j.Level; | |
14 | ||
15 | import gov .va.ccrs.h elpers.Log Helper; | |
16 | import gov .va.ccrs.h elpers.Pro pertiesHel per; | |
17 | ||
18 | /** | |
19 | * @author PII | |
20 | * | |
21 | */ | |
22 | public cla ss DBUtil { | |
23 | ||
24 | public static Co nnection g etSQLConne ction() th rows Excep tion { | |
25 | Co nnection o Conn = nul l; | |
26 | St ring conne ctionURL = String.fo rmat("jdbc :sqlserver ://%s;user =%s;passwo rd=%s;data baseName=% s" | |
27 | , Pr opertiesHe lper.getPr operty("sq l.serverna me") | |
28 | , Pr opertiesHe lper.getPr operty("sq l.username ") | |
29 | , Pr opertiesHe lper.getPr operty("sq l.passowrd ") | |
30 | , Pr opertiesHe lper.getPr operty("sq l.database Name")); | |
31 | oC onn = Driv erManager. getConnect ion(connec tionURL); | |
32 | ||
33 | re turn oConn ; | |
34 | } | |
35 | ||
36 | ||
37 | public static St ring getDB Value(Resu ltSet rec, String fi eldName) t hrows Exce ption{ | |
38 | ||
39 | retu rn rec.get String(fie ldName) != null ? re c.getStrin g(fieldNam e):""; | |
40 | } | |
41 | ||
42 | public static St ring creat eHeader(Re sultSetMet aData rsmd ) throws E xception | |
43 | { | |
44 | Stri ngBuilder sBuffer = new String Builder(); | |
45 | int ColumnCoun t = rsmd.g etColumnCo unt(); | |
46 | int i; | |
47 | for (i = 1; i <= ColumnCou nt; i++) | |
48 | { | |
49 | sBuffe r.append(r smd.getCol umnName(i) ) | |
50 | .appen d(","); | |
51 | } | |
52 | re turn(sBuff er.toStrin g()); | |
53 | ||
54 | } | |
55 | ||
56 | pu blic stati c String a ddDetailLi nes(Result SetMetaDat a rsmd, Re sultSet re c) throws Exception | |
57 | { | |
58 | Stri ngBuilder sBuffer = new String Builder(); | |
59 | int ColumnCoun t = rsmd.g etColumnCo unt(); | |
60 | int i; | |
61 | ||
62 | ||
63 | for (i = 1; i <= ColumnCou nt; i++) | |
64 | { | |
65 | String ColumnNam e = rsmd.g etColumnNa me(i); | |
66 | sBuffe r.append(D BUtil.getD BValue(rec , ColumnNa me)) | |
67 | .appen d(","); | |
68 | } | |
69 | ||
70 | retu rn (sBuffe r.toString ()); | |
71 | } | |
72 | ||
73 | pu blic stati c String b uildFileNa me(String fileName) throws Exc eption | |
74 | { | |
75 | Stri ng SimpleD ateFormat = new Simp leDateForm at("MMddyy yy").forma t(new Date ()); | |
76 | ||
77 | Stri ng path = String.for mat("%s/%s ", Propert iesHelper. getPropert y("filePat h"), | |
78 | Properti esHelper.g etProperty (fileName) + SimpleD ateFormat + ".csv"); | |
79 | ||
80 | retu rn(path); | |
81 | } | |
82 | ||
83 | /* * | |
84 | * @param st oredProcNa me | |
85 | * @return | |
86 | * @throws E xception | |
87 | * / | |
88 | pu blic stati c ResultSe t getData( String sto redProcNam e) throws Exception | |
89 | { | |
90 | Conn ection con nect = nul l; | |
91 | Call ableStatem ent callab leStatemen t = null; | |
92 | ||
93 | conn ect = DBUt il.getSQLC onnection( ); | |
94 | ||
95 | Stri ng getDBUS ERByUserId Sql = "{ca ll [dbo].[ "+storedPr ocName+"]} "; | |
96 | call ableStatem ent = conn ect.prepar eCall(getD BUSERByUse rIdSql); | |
97 | ||
98 | // e xecute get DBUSERByUs erId store procedure | |
99 | if(c allableSta tement.exe cute()) | |
100 | { | |
101 | return (callableS tatement.g etResultSe t()); | |
102 | }els e | |
103 | { | |
104 | return (null); | |
105 | } | |
106 | } | |
107 | ||
108 | ||
109 | pu blic stati c void get Report(Str ing stored ProcName, String fil eName) | |
110 | ||
111 | { | |
112 | try | |
113 | { | |
114 | Result Set rec = getData(st oredProcNa me); | |
115 | Result SetMetaDat a rsmd = rec.getMet aData(); | |
116 | if (re c != null) | |
117 | { | |
118 | try(File Writer wri ter = new FileWriter (buildFile Name(fileN ame), fals e)) | |
119 | { | |
120 | writer.app end(create Header(rsm d)); | |
121 | writer.wri te("\r\n") ; | |
122 | while (( rec != nul l) && (rec .next())) | |
123 | { | |
124 | wr iter.appen d(addDetai lLines(rsm d, rec)); | |
125 | wr iter.write ("\r\n"); | |
126 | } | |
127 | } | |
128 | } | |
129 | ||
130 | } | |
131 | catc h (Excepti on e) | |
132 | { | |
133 | LogHel per.Log(Le vel.ERROR, e); | |
134 | } | |
135 | } | |
136 | ||
137 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.