Lauren Green vor 6 Jahren
Ursprung
Commit
744f86d364

+ 1
- 0
.idea/.name Datei anzeigen

@@ -0,0 +1 @@
1
+simpleAccount

+ 13
- 0
.idea/compiler.xml Datei anzeigen

@@ -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="simpleAccount" />
10
+      </profile>
11
+    </annotationProcessing>
12
+  </component>
13
+</project>

+ 14
- 0
.idea/misc.xml Datei anzeigen

@@ -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 Datei anzeigen

@@ -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>

+ 413
- 0
.idea/workspace.xml Datei anzeigen

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

+ 34
- 0
pom.xml Datei anzeigen

@@ -0,0 +1,34 @@
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>laurenstewartgreen</groupId>
8
+    <artifactId>simpleAccount</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>4.48</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>4.48</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>5.1.6</version>
31
+    </dependency>
32
+    </dependencies>
33
+
34
+</project>

+ 2
- 0
simpleAccount.iml Datei anzeigen

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

+ 64
- 0
src/main/java/Account.java Datei anzeigen

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

+ 65
- 0
src/main/java/AccountApp.java Datei anzeigen

@@ -0,0 +1,65 @@
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
+public class AccountApp {
7
+
8
+    // we are using a MySQl database
9
+    private final static String DATABASE_URL = "jdbc:mysql://localhost:3306/orm_lab?useUnicode=true";
10
+
11
+    private Dao<Account, Integer> accountDao;
12
+
13
+    public static void main(String[] args) throws Exception {
14
+        // turn our static method into an instance of Main
15
+        new AccountApp().doMain(args);
16
+    }
17
+
18
+    private void doMain(String[] args) throws Exception {
19
+        ConnectionSource connectionSource = null;
20
+        try {
21
+            // create our data-source for the database
22
+            connectionSource = new JdbcConnectionSource(DATABASE_URL, YOURUSERNAME, YOURPASSWORD);
23
+            // setup our  DAOs
24
+            setupDao(connectionSource);
25
+            // read, write and delete some data
26
+            processData();
27
+
28
+            System.out.println("\n\nIt seems to have worked\n\n");
29
+        } finally {
30
+            // destroy the data source which should close underlying connections
31
+            if (connectionSource != null) {
32
+                connectionSource.close();
33
+            }
34
+        }
35
+    }
36
+
37
+    /**
38
+     * Read and write some example data.
39
+     */
40
+    private void processData() throws Exception {
41
+        // create an instance of Account
42
+        String name = "Jim Coakley";
43
+        Account account = new Account(name);
44
+
45
+        // persist the account object to the database
46
+        accountDao.create(account);
47
+        int id = account.getId();
48
+        System.out.println(id);
49
+        // assign a password
50
+        account.setPassword("_secret");
51
+        // update the database after changing the object
52
+        accountDao.update(account);
53
+        // delete the account
54
+        //accountDao.deleteById(id);
55
+    }
56
+
57
+    /**
58
+     * Setup our  DAOs
59
+     */
60
+    private void setupDao(ConnectionSource connectionSource) throws Exception {
61
+
62
+        accountDao = DaoManager.createDao(connectionSource, Account.class);
63
+
64
+    }
65
+}

BIN
target/classes/Account.class Datei anzeigen


BIN
target/classes/AccountApp.class Datei anzeigen