ThuyKhong 6 years ago
parent
commit
754996da1c

+ 1
- 0
.idea/.name View File

@@ -0,0 +1 @@
1
+ORMLab

+ 13
- 0
.idea/compiler.xml View File

@@ -0,0 +1,13 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="CompilerConfiguration">
4
+    <annotationProcessing>
5
+      <profile name="Maven default annotation processors profile" enabled="true">
6
+        <sourceOutputDir name="target/generated-sources/annotations" />
7
+        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
8
+        <outputRelativeToContentRoot value="true" />
9
+        <module name="ZCW-ORM-SimpleAccount" />
10
+      </profile>
11
+    </annotationProcessing>
12
+  </component>
13
+</project>

+ 14
- 0
.idea/misc.xml View File

@@ -0,0 +1,14 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+  <component name="MavenProjectsManager">
5
+    <option name="originalFiles">
6
+      <list>
7
+        <option value="$PROJECT_DIR$/pom.xml" />
8
+      </list>
9
+    </option>
10
+  </component>
11
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
12
+    <output url="file://$PROJECT_DIR$/out" />
13
+  </component>
14
+</project>

+ 6
- 0
.idea/vcs.xml View File

@@ -0,0 +1,6 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="VcsDirectoryMappings">
4
+    <mapping directory="" vcs="Git" />
5
+  </component>
6
+</project>

+ 446
- 0
.idea/workspace.xml View File

@@ -0,0 +1,446 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="b54b89e8-61d8-4506-8bc0-92d6ac07af47" name="Default Changelist" comment="">
5
+      <change afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
7
+      <change afterPath="$PROJECT_DIR$/src/main/java/Account.java" afterDir="false" />
8
+      <change afterPath="$PROJECT_DIR$/src/main/java/AccountApp.java" afterDir="false" />
9
+    </list>
10
+    <ignored path="$PROJECT_DIR$/out/" />
11
+    <ignored path="$PROJECT_DIR$/target/" />
12
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
13
+    <option name="SHOW_DIALOG" value="false" />
14
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
15
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
16
+    <option name="LAST_RESOLUTION" value="IGNORE" />
17
+  </component>
18
+  <component name="FUSProjectUsageTrigger">
19
+    <session id="1071499918">
20
+      <usages-collector id="statistics.lifecycle.project">
21
+        <counts>
22
+          <entry key="project.closed" value="1" />
23
+          <entry key="project.open.time.1" value="1" />
24
+          <entry key="project.open.time.3" value="1" />
25
+          <entry key="project.opened" value="2" />
26
+        </counts>
27
+      </usages-collector>
28
+      <usages-collector id="statistics.file.extensions.open">
29
+        <counts>
30
+          <entry key="class" value="3" />
31
+          <entry key="java" value="4" />
32
+          <entry key="xml" value="1" />
33
+        </counts>
34
+      </usages-collector>
35
+      <usages-collector id="statistics.file.types.open">
36
+        <counts>
37
+          <entry key="CLASS" value="3" />
38
+          <entry key="JAVA" value="4" />
39
+          <entry key="XML" value="1" />
40
+        </counts>
41
+      </usages-collector>
42
+      <usages-collector id="statistics.file.extensions.edit">
43
+        <counts>
44
+          <entry key="java" value="2638" />
45
+          <entry key="xml" value="17" />
46
+        </counts>
47
+      </usages-collector>
48
+      <usages-collector id="statistics.file.types.edit">
49
+        <counts>
50
+          <entry key="JAVA" value="2638" />
51
+          <entry key="XML" value="17" />
52
+        </counts>
53
+      </usages-collector>
54
+    </session>
55
+  </component>
56
+  <component name="FileEditorManager">
57
+    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
58
+      <file pinned="false" current-in-tab="false">
59
+        <entry file="jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar!/com/mysql/jdbc/ConnectionPropertiesImpl.class">
60
+          <provider selected="true" editor-type-id="text-editor">
61
+            <state relative-caret-position="120">
62
+              <caret line="24" column="83" selection-start-line="24" selection-start-column="83" selection-end-line="24" selection-end-column="83" />
63
+            </state>
64
+          </provider>
65
+        </entry>
66
+      </file>
67
+      <file pinned="false" current-in-tab="false">
68
+        <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-jdbc/4.48/ormlite-jdbc-4.48.jar!/com/j256/ormlite/jdbc/DataSourceConnectionSource.class">
69
+          <provider selected="true" editor-type-id="text-editor">
70
+            <state relative-caret-position="270">
71
+              <caret line="30" column="39" selection-start-line="30" selection-start-column="39" selection-end-line="30" selection-end-column="39" />
72
+            </state>
73
+          </provider>
74
+        </entry>
75
+      </file>
76
+      <file pinned="false" current-in-tab="false">
77
+        <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
78
+          <provider selected="true" editor-type-id="text-editor">
79
+            <state relative-caret-position="180">
80
+              <caret line="12" selection-start-line="12" selection-end-line="12" />
81
+              <folding>
82
+                <element signature="imports" expanded="true" />
83
+              </folding>
84
+            </state>
85
+          </provider>
86
+        </entry>
87
+      </file>
88
+      <file pinned="false" current-in-tab="true">
89
+        <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
90
+          <provider selected="true" editor-type-id="text-editor">
91
+            <state relative-caret-position="2055">
92
+              <caret line="139" column="12" selection-start-line="139" selection-start-column="12" selection-end-line="139" selection-end-column="12" />
93
+              <folding>
94
+                <element signature="imports" expanded="true" />
95
+                <element signature="e#5945#5946#0" expanded="true" />
96
+                <element signature="e#5972#5973#0" expanded="true" />
97
+              </folding>
98
+            </state>
99
+          </provider>
100
+        </entry>
101
+      </file>
102
+    </leaf>
103
+  </component>
104
+  <component name="FileTemplateManagerImpl">
105
+    <option name="RECENT_TEMPLATES">
106
+      <list>
107
+        <option value="Class" />
108
+      </list>
109
+    </option>
110
+  </component>
111
+  <component name="Git.Settings">
112
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
113
+  </component>
114
+  <component name="IdeDocumentHistory">
115
+    <option name="CHANGED_PATHS">
116
+      <list>
117
+        <option value="$PROJECT_DIR$/src/main/java/Account.java" />
118
+        <option value="$PROJECT_DIR$/pom.xml" />
119
+        <option value="$PROJECT_DIR$/src/test/java/TestAccountService.java" />
120
+        <option value="$PROJECT_DIR$/src/main/java/AccountService.java" />
121
+        <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
122
+      </list>
123
+    </option>
124
+  </component>
125
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
126
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
127
+  <component name="JsGulpfileManager">
128
+    <detection-done>true</detection-done>
129
+    <sorting>DEFINITION_ORDER</sorting>
130
+  </component>
131
+  <component name="MavenImportPreferences">
132
+    <option name="importingSettings">
133
+      <MavenImportingSettings>
134
+        <option name="importAutomatically" value="true" />
135
+      </MavenImportingSettings>
136
+    </option>
137
+  </component>
138
+  <component name="MavenProjectNavigator">
139
+    <treeState>
140
+      <expand>
141
+        <path>
142
+          <item name="" type="16c1761:MavenProjectsStructure$RootNode" />
143
+          <item name="ORMLab" type="9519ce18:MavenProjectsStructure$ProjectNode" />
144
+        </path>
145
+      </expand>
146
+      <select />
147
+    </treeState>
148
+  </component>
149
+  <component name="ProjectFrameBounds">
150
+    <option name="x" value="39" />
151
+    <option name="y" value="23" />
152
+    <option name="width" value="1329" />
153
+    <option name="height" value="797" />
154
+  </component>
155
+  <component name="ProjectView">
156
+    <navigator proportions="" version="1">
157
+      <foldersAlwaysOnTop value="true" />
158
+    </navigator>
159
+    <panes>
160
+      <pane id="ProjectPane">
161
+        <subPane>
162
+          <expand>
163
+            <path>
164
+              <item name="ORMLab" type="b2602c69:ProjectViewProjectNode" />
165
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
166
+            </path>
167
+            <path>
168
+              <item name="ORMLab" type="b2602c69:ProjectViewProjectNode" />
169
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
170
+              <item name="src" type="462c0819:PsiDirectoryNode" />
171
+            </path>
172
+            <path>
173
+              <item name="ORMLab" type="b2602c69:ProjectViewProjectNode" />
174
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
175
+              <item name="src" type="462c0819:PsiDirectoryNode" />
176
+              <item name="main" type="462c0819:PsiDirectoryNode" />
177
+            </path>
178
+            <path>
179
+              <item name="ORMLab" type="b2602c69:ProjectViewProjectNode" />
180
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
181
+              <item name="src" type="462c0819:PsiDirectoryNode" />
182
+              <item name="main" type="462c0819:PsiDirectoryNode" />
183
+              <item name="java" type="462c0819:PsiDirectoryNode" />
184
+            </path>
185
+            <path>
186
+              <item name="ORMLab" type="b2602c69:ProjectViewProjectNode" />
187
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
188
+              <item name="src" type="462c0819:PsiDirectoryNode" />
189
+              <item name="test" type="462c0819:PsiDirectoryNode" />
190
+            </path>
191
+            <path>
192
+              <item name="ORMLab" type="b2602c69:ProjectViewProjectNode" />
193
+              <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
194
+            </path>
195
+          </expand>
196
+          <select />
197
+        </subPane>
198
+      </pane>
199
+      <pane id="Scope" />
200
+      <pane id="PackagesPane" />
201
+    </panes>
202
+  </component>
203
+  <component name="PropertiesComponent">
204
+    <property name="SearchEverywhereHistoryKey" value="server time&#9;PSI&#9;JAVA://com.mysql.jdbc.ConnectionPropertiesImpl#serverTimezone" />
205
+    <property name="WebServerToolWindowFactoryState" value="false" />
206
+    <property name="aspect.path.notification.shown" value="true" />
207
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1542510852630" />
208
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
209
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
210
+    <property name="project.structure.last.edited" value="Modules" />
211
+    <property name="project.structure.proportion" value="0.15" />
212
+    <property name="project.structure.side.proportion" value="0.2" />
213
+  </component>
214
+  <component name="RunDashboard">
215
+    <option name="ruleStates">
216
+      <list>
217
+        <RuleState>
218
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
219
+        </RuleState>
220
+        <RuleState>
221
+          <option name="name" value="StatusDashboardGroupingRule" />
222
+        </RuleState>
223
+      </list>
224
+    </option>
225
+  </component>
226
+  <component name="RunManager">
227
+    <configuration name="AccountApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
228
+      <option name="MAIN_CLASS_NAME" value="AccountApp" />
229
+      <module name="ZCW-ORM-SimpleAccount" />
230
+      <method v="2">
231
+        <option name="Make" enabled="true" />
232
+      </method>
233
+    </configuration>
234
+    <recent_temporary>
235
+      <list>
236
+        <item itemvalue="Application.AccountApp" />
237
+      </list>
238
+    </recent_temporary>
239
+  </component>
240
+  <component name="SvnConfiguration">
241
+    <configuration />
242
+  </component>
243
+  <component name="TaskManager">
244
+    <task active="true" id="Default" summary="Default task">
245
+      <changelist id="b54b89e8-61d8-4506-8bc0-92d6ac07af47" name="Default Changelist" comment="" />
246
+      <created>1542393385132</created>
247
+      <option name="number" value="Default" />
248
+      <option name="presentableId" value="Default" />
249
+      <updated>1542393385132</updated>
250
+      <workItem from="1542393386723" duration="12143000" />
251
+      <workItem from="1542508664790" duration="2108000" />
252
+    </task>
253
+    <servers />
254
+  </component>
255
+  <component name="TimeTrackingManager">
256
+    <option name="totallyTimeSpent" value="14251000" />
257
+  </component>
258
+  <component name="ToolWindowManager">
259
+    <frame x="39" y="23" width="1329" height="797" extended-state="0" />
260
+    <editor active="true" />
261
+    <layout>
262
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.17171717" />
263
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
264
+      <window_info id="Image Layers" order="2" />
265
+      <window_info id="Designer" order="3" />
266
+      <window_info id="UI Designer" order="4" />
267
+      <window_info id="Capture Tool" order="5" />
268
+      <window_info id="Favorites" order="6" side_tool="true" />
269
+      <window_info anchor="bottom" id="Message" order="0" />
270
+      <window_info anchor="bottom" id="Find" order="1" />
271
+      <window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32991204" />
272
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
273
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
274
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
275
+      <window_info anchor="bottom" id="TODO" order="6" />
276
+      <window_info anchor="bottom" id="Version Control" order="7" />
277
+      <window_info anchor="bottom" id="Database Changes" order="8" show_stripe_button="false" />
278
+      <window_info anchor="bottom" id="Terminal" order="9" weight="0.32991204" />
279
+      <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
280
+      <window_info anchor="bottom" id="Messages" order="11" weight="0.32991204" />
281
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
282
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
283
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
284
+      <window_info anchor="right" id="Palette" order="3" />
285
+      <window_info anchor="right" id="Capture Analysis" order="4" />
286
+      <window_info anchor="right" id="Database" order="5" />
287
+      <window_info anchor="right" id="Theme Preview" order="6" />
288
+      <window_info anchor="right" id="Palette&#9;" order="7" />
289
+      <window_info anchor="right" id="Maven Projects" order="8" weight="0.32897383" />
290
+    </layout>
291
+  </component>
292
+  <component name="TypeScriptGeneratedFilesManager">
293
+    <option name="version" value="1" />
294
+  </component>
295
+  <component name="VcsContentAnnotationSettings">
296
+    <option name="myLimit" value="2678400000" />
297
+  </component>
298
+  <component name="editorHistoryManager">
299
+    <entry file="jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar!/com/mysql/jdbc/JDBC4Connection.class">
300
+      <provider selected="true" editor-type-id="text-editor">
301
+        <state relative-caret-position="99">
302
+          <caret line="33" column="13" selection-start-line="33" selection-start-column="13" selection-end-line="33" selection-end-column="13" />
303
+        </state>
304
+      </provider>
305
+    </entry>
306
+    <entry file="file://$PROJECT_DIR$/src/test/java/TestAccountService.java" />
307
+    <entry file="file://$PROJECT_DIR$/pom.xml">
308
+      <provider selected="true" editor-type-id="text-editor">
309
+        <state relative-caret-position="450">
310
+          <caret line="30" selection-start-line="30" selection-end-line="30" />
311
+        </state>
312
+      </provider>
313
+    </entry>
314
+    <entry file="jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar!/com/mysql/jdbc/ConnectionPropertiesImpl.class">
315
+      <provider selected="true" editor-type-id="text-editor">
316
+        <state relative-caret-position="120">
317
+          <caret line="24" column="83" selection-start-line="24" selection-start-column="83" selection-end-line="24" selection-end-column="83" />
318
+        </state>
319
+      </provider>
320
+    </entry>
321
+    <entry file="jar://$MAVEN_REPOSITORY$/com/j256/ormlite/ormlite-jdbc/4.48/ormlite-jdbc-4.48.jar!/com/j256/ormlite/jdbc/DataSourceConnectionSource.class">
322
+      <provider selected="true" editor-type-id="text-editor">
323
+        <state relative-caret-position="270">
324
+          <caret line="30" column="39" selection-start-line="30" selection-start-column="39" selection-end-line="30" selection-end-column="39" />
325
+        </state>
326
+      </provider>
327
+    </entry>
328
+    <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
329
+      <provider selected="true" editor-type-id="text-editor">
330
+        <state relative-caret-position="180">
331
+          <caret line="12" selection-start-line="12" selection-end-line="12" />
332
+          <folding>
333
+            <element signature="imports" expanded="true" />
334
+          </folding>
335
+        </state>
336
+      </provider>
337
+    </entry>
338
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountService.java">
339
+      <provider selected="true" editor-type-id="text-editor">
340
+        <state relative-caret-position="90">
341
+          <caret line="6" column="6" lean-forward="true" selection-end-line="109" />
342
+        </state>
343
+      </provider>
344
+    </entry>
345
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
346
+      <provider selected="true" editor-type-id="text-editor">
347
+        <state relative-caret-position="2055">
348
+          <caret line="139" column="12" selection-start-line="139" selection-start-column="12" selection-end-line="139" selection-end-column="12" />
349
+          <folding>
350
+            <element signature="imports" expanded="true" />
351
+            <element signature="e#5945#5946#0" expanded="true" />
352
+            <element signature="e#5972#5973#0" expanded="true" />
353
+          </folding>
354
+        </state>
355
+      </provider>
356
+    </entry>
357
+  </component>
358
+  <component name="masterDetails">
359
+    <states>
360
+      <state key="ArtifactsStructureConfigurable.UI">
361
+        <settings>
362
+          <artifact-editor />
363
+          <splitter-proportions>
364
+            <option name="proportions">
365
+              <list>
366
+                <option value="0.2" />
367
+              </list>
368
+            </option>
369
+          </splitter-proportions>
370
+        </settings>
371
+      </state>
372
+      <state key="FacetStructureConfigurable.UI">
373
+        <settings>
374
+          <last-edited>No facets are configured</last-edited>
375
+          <splitter-proportions>
376
+            <option name="proportions">
377
+              <list>
378
+                <option value="0.2" />
379
+              </list>
380
+            </option>
381
+          </splitter-proportions>
382
+        </settings>
383
+      </state>
384
+      <state key="GlobalLibrariesConfigurable.UI">
385
+        <settings>
386
+          <splitter-proportions>
387
+            <option name="proportions">
388
+              <list>
389
+                <option value="0.2" />
390
+              </list>
391
+            </option>
392
+          </splitter-proportions>
393
+        </settings>
394
+      </state>
395
+      <state key="JdkListConfigurable.UI">
396
+        <settings>
397
+          <last-edited>1.8</last-edited>
398
+          <splitter-proportions>
399
+            <option name="proportions">
400
+              <list>
401
+                <option value="0.2" />
402
+              </list>
403
+            </option>
404
+          </splitter-proportions>
405
+        </settings>
406
+      </state>
407
+      <state key="ModuleStructureConfigurable.UI">
408
+        <settings>
409
+          <last-edited>ZCW-ORM-SimpleAccount</last-edited>
410
+          <splitter-proportions>
411
+            <option name="proportions">
412
+              <list>
413
+                <option value="0.2" />
414
+                <option value="0.6" />
415
+              </list>
416
+            </option>
417
+          </splitter-proportions>
418
+        </settings>
419
+      </state>
420
+      <state key="ProjectJDKs.UI">
421
+        <settings>
422
+          <last-edited>1.8</last-edited>
423
+          <splitter-proportions>
424
+            <option name="proportions">
425
+              <list>
426
+                <option value="0.2" />
427
+              </list>
428
+            </option>
429
+          </splitter-proportions>
430
+        </settings>
431
+      </state>
432
+      <state key="ProjectLibrariesConfigurable.UI">
433
+        <settings>
434
+          <last-edited>Maven: com.google.protobuf:protobuf-java:3.6.1</last-edited>
435
+          <splitter-proportions>
436
+            <option name="proportions">
437
+              <list>
438
+                <option value="0.2" />
439
+              </list>
440
+            </option>
441
+          </splitter-proportions>
442
+        </settings>
443
+      </state>
444
+    </states>
445
+  </component>
446
+</project>

+ 2
- 0
ZCW-ORM-SimpleAccount.iml View File

@@ -0,0 +1,2 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="JAVA_MODULE" version="4" />

+ 36
- 0
pom.xml View File

@@ -0,0 +1,36 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <modelVersion>4.0.0</modelVersion>
6
+
7
+    <groupId>MyGroupId</groupId>
8
+    <artifactId>ORMLab</artifactId>
9
+    <version>1.0-SNAPSHOT</version>
10
+
11
+    <dependencies>
12
+    <!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-core -->
13
+    <dependency>
14
+        <groupId>com.j256.ormlite</groupId>
15
+        <artifactId>ormlite-core</artifactId>
16
+        <version>5.1</version>
17
+    </dependency>
18
+
19
+    <!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-jdbc -->
20
+    <dependency>
21
+        <groupId>com.j256.ormlite</groupId>
22
+        <artifactId>ormlite-jdbc</artifactId>
23
+        <version>5.1</version>
24
+    </dependency>
25
+
26
+    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
27
+    <dependency>
28
+        <groupId>mysql</groupId>
29
+        <artifactId>mysql-connector-java</artifactId>
30
+        <version>8.0.13</version>
31
+    </dependency>
32
+
33
+    </dependencies>
34
+
35
+
36
+</project>

+ 66
- 0
src/main/java/Account.java View File

@@ -0,0 +1,66 @@
1
+
2
+import com.j256.ormlite.field.DatabaseField;
3
+import com.j256.ormlite.table.DatabaseTable;
4
+
5
+    @DatabaseTable(tableName = "account")
6
+    public class Account {
7
+
8
+        public static final String NAME_FIELD_NAME = "name";
9
+        public static final String PASSWORD_FIELD_NAME = "password";
10
+
11
+        @DatabaseField(columnName = "id", generatedId = true)
12
+        private int id;
13
+
14
+        @DatabaseField(columnName = "name", canBeNull = false)
15
+        private String name;
16
+
17
+        @DatabaseField(columnName = "password")
18
+        private String password;
19
+
20
+        Account() {
21
+            // all persisted classes must define a no-arg constructor with at least package visibility
22
+        }
23
+
24
+        public Account(String name) {
25
+            this.name = name;
26
+        }
27
+
28
+        public Account(String name, String password) {
29
+            this.name = name;
30
+            this.password = password;
31
+        }
32
+
33
+        public int getId() {
34
+            return id;
35
+        }
36
+
37
+        public String getName() {
38
+            return name;
39
+        }
40
+
41
+        public void setName(String name) {
42
+            this.name = name;
43
+        }
44
+
45
+        public String getPassword() {
46
+            return password;
47
+        }
48
+
49
+        public void setPassword(String password) {
50
+            this.password = password;
51
+        }
52
+
53
+        @Override
54
+        public int hashCode() {
55
+            return name.hashCode();
56
+        }
57
+
58
+        @Override
59
+        public boolean equals(Object other) {
60
+            if (other == null || other.getClass() != getClass()) {
61
+                return false;
62
+            }
63
+            return name.equals(((Account) other).name);
64
+        }
65
+    }
66
+

+ 204
- 0
src/main/java/AccountApp.java View File

@@ -0,0 +1,204 @@
1
+import com.j256.ormlite.dao.Dao;
2
+import com.j256.ormlite.dao.DaoManager;
3
+import com.j256.ormlite.jdbc.JdbcConnectionSource;
4
+import com.j256.ormlite.support.ConnectionSource;
5
+
6
+import java.sql.SQLException;
7
+
8
+import java.sql.SQLException;
9
+import java.util.Scanner;
10
+
11
+public class AccountApp {
12
+    static Scanner scan = new Scanner(System.in);
13
+    private boolean quit;
14
+
15
+    // we are using a MySQl database
16
+    private final static String DATABASE_URL = "jdbc:mysql://localhost:3306/orm_lab?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
17
+
18
+    private Dao<Account, Integer> accountDao;
19
+
20
+    public static void main(String[] args) throws Exception {
21
+        // turn our static method into an instance of Main
22
+        new AccountApp().doMain(args);
23
+    }
24
+
25
+    private void doMain(String[] args) throws Exception {
26
+        ConnectionSource connectionSource = null;
27
+        try {
28
+            // create our data-source for the database
29
+            connectionSource = new JdbcConnectionSource(DATABASE_URL, "root", "");
30
+            // setup our  DAOs
31
+            setupDao(connectionSource);
32
+            // read, write and delete some data
33
+            try {
34
+                processData();
35
+            }catch (NullPointerException e){
36
+
37
+            }
38
+//            System.out.println("\n\nIt seems to have worked\n\n");
39
+        } finally {
40
+            // destroy the data source which should close underlying connections
41
+            if (connectionSource != null) {
42
+                connectionSource.close();
43
+            }
44
+        }
45
+    }
46
+
47
+    /**
48
+     * Read and write some example data.
49
+     */
50
+//    private void processData() throws Exception {
51
+//        // create an instance of Account
52
+//        String name = "Jim Coakley";
53
+//        Account account = new Account(name);
54
+//
55
+//        // persist the account object to the database
56
+//        accountDao.create(account);
57
+//        int id = account.getId();
58
+//        System.out.println(id);
59
+//        // assign a password
60
+//        account.setPassword("_secret");
61
+//        // update the database after changing the object
62
+//        accountDao.update(account);
63
+//        // delete the account
64
+//        //accountDao.deleteById(id);
65
+//    }
66
+    public void processData() throws Exception{
67
+
68
+        while(quit == false) {
69
+            printPrompt(selectMenu());
70
+            int input = scan.nextInt();
71
+            scan.nextLine();
72
+            switch(input) {
73
+                case 1: createAccount(); break;
74
+                case 2: updateAccount(); break;
75
+                case 3: retrieveAccount(); break;
76
+                case 4: deleteAccount(); break;
77
+                case 5: break;
78
+                default: printPrompt("Invalid input.\n" + selectMenu());
79
+            }
80
+            quit= true;
81
+        }
82
+    }
83
+
84
+    public void printPrompt(String prompt){
85
+        System.out.println(prompt);
86
+    }
87
+
88
+    public String selectMenu(){
89
+        return "Please select an option:\n" +
90
+                "1) Create account\n" +
91
+                "2) Update account\n" +
92
+                "3) Retrieve account\n" +
93
+                "4) Delete account\n" +
94
+                "5) Exit";
95
+    }
96
+
97
+    public void createAccount() throws SQLException {
98
+        printPrompt("Please enter name for the account.");
99
+        String name = scan.nextLine();
100
+        Account newAccount = new Account(name);
101
+        accountDao.create(newAccount);
102
+        int accountID = newAccount.getId();
103
+        printPrompt("Your account has been created.\n" +
104
+                "Your account ID is "+accountID + " name is " + newAccount.getName());
105
+        printPrompt("Please create a password.");
106
+        String pw = scan.nextLine();
107
+        newAccount.setPassword(pw);
108
+        accountDao.update(newAccount);
109
+
110
+        try{
111
+            processData();
112
+        }catch (Exception e){
113
+
114
+        }
115
+    }
116
+
117
+    public void retrieveAccount() throws SQLException{
118
+        printPrompt("Please enter your account ID.");
119
+        int accountID = scan.nextInt();
120
+        scan.nextLine();
121
+        Account account = accountDao.queryForId(accountID);
122
+        printPrompt(String.format("ID: %d; Name: %s; Password: %s", account.getId(), account.getName(), account.getPassword()));
123
+
124
+        try{
125
+            processData();
126
+        }catch (Exception e){
127
+
128
+        }
129
+    }
130
+
131
+    public void updateAccount() throws SQLException{
132
+        printPrompt("Please enter your account ID.");
133
+        int accountID = scan.nextInt();
134
+        scan.nextLine();
135
+
136
+        Account account = accountDao.queryForId(accountID);
137
+        printPrompt(selectUpdate());
138
+        int input = scan.nextInt();
139
+        scan.nextLine();
140
+        switch(input) {
141
+            case 1: updateName(account);
142
+                printPrompt("Your account name has been updated to " + account.getName());
143
+                break;
144
+            case 2: updatePassword(account);
145
+                printPrompt("Your account password has been updated.");
146
+                break;
147
+            default: printPrompt("Invalid input.\n" + selectUpdate());
148
+        }
149
+        try{
150
+            processData();
151
+        }catch (Exception e){
152
+
153
+        }
154
+    }
155
+
156
+    public String selectUpdate(){
157
+        return "What do you want to update?\n" +
158
+                "1) Name " +
159
+                "2) Password";
160
+    }
161
+
162
+    public void updatePassword(Account account) throws SQLException{
163
+        printPrompt("Please enter a new password.");
164
+        String pw = scan.nextLine();
165
+        account.setPassword(pw);
166
+        accountDao.update(account);
167
+    }
168
+
169
+    public void updateName(Account account) throws  SQLException{
170
+        printPrompt("Please enter a new name.");
171
+        String name = scan.nextLine();
172
+        account.setName(name);
173
+        accountDao.update(account);
174
+    }
175
+
176
+
177
+    public void deleteAccount() throws SQLException{
178
+        printPrompt("Please enter account ID to delete.");
179
+        int accountID = scan.nextInt();
180
+        scan.nextLine();
181
+        Account account =  accountDao.queryForId(accountID);
182
+        accountDao.delete(account);
183
+        printPrompt("Account "+ accountID + " has been deleted.");
184
+
185
+        try{
186
+            processData();
187
+        }catch (Exception e){
188
+
189
+        }
190
+    }
191
+
192
+    public boolean quit(){
193
+        return true;
194
+    }
195
+
196
+    /**
197
+     * Setup our  DAOs
198
+     */
199
+    private void setupDao(ConnectionSource connectionSource) throws Exception {
200
+
201
+        accountDao = DaoManager.createDao(connectionSource, Account.class);
202
+
203
+    }
204
+}

BIN
target/classes/Account.class View File


BIN
target/classes/AccountApp.class View File