Nathan Hall vor 5 Jahren
Ursprung
Commit
c65077b312

+ 1
- 0
.idea/.name Datei anzeigen

@@ -0,0 +1 @@
1
+ormSimpleAccount

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

+ 15
- 0
.idea/dataSources.local.xml Datei anzeigen

@@ -0,0 +1,15 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="dataSourceStorageLocal">
4
+    <data-source name="@localhost" uuid="3c46b28a-50b3-4b19-a8e9-11b7b846b04d">
5
+      <database-info product="MySQL" version="8.0.12" jdbc-version="4.0" driver-name="MySQL Connector Java" driver-version="mysql-connector-java-5.1.46 ( Revision: 9cc87a48e75c2d2e87c1a293b2862ce651cb256e )" family="MYSQL" exact-version="8.0.12">
6
+        <extra-name-characters>#@</extra-name-characters>
7
+        <identifier-quote-string>`</identifier-quote-string>
8
+      </database-info>
9
+      <case-sensitivity plain-identifiers="mixed" quoted-identifiers="upper" />
10
+      <secret-storage>master_key</secret-storage>
11
+      <user-name>root</user-name>
12
+      <introspection-schemas>*:@</introspection-schemas>
13
+    </data-source>
14
+  </component>
15
+</project>

+ 19
- 0
.idea/dataSources.xml Datei anzeigen

@@ -0,0 +1,19 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
4
+    <data-source source="LOCAL" name="@localhost" uuid="3c46b28a-50b3-4b19-a8e9-11b7b846b04d">
5
+      <driver-ref>mysql</driver-ref>
6
+      <synchronize>true</synchronize>
7
+      <jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
8
+      <jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
9
+      <driver-properties>
10
+        <property name="autoReconnect" value="true" />
11
+        <property name="zeroDateTimeBehavior" value="convertToNull" />
12
+        <property name="tinyInt1isBit" value="false" />
13
+        <property name="characterEncoding" value="utf8" />
14
+        <property name="characterSetResults" value="utf8" />
15
+        <property name="yearIsDateType" value="false" />
16
+      </driver-properties>
17
+    </data-source>
18
+  </component>
19
+</project>

+ 4146
- 0
.idea/dataSources/3c46b28a-50b3-4b19-a8e9-11b7b846b04d.xml
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


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

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

@@ -0,0 +1,318 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="5201bf50-7c34-4b6d-8010-7ae925bc926d" name="Default Changelist" comment="">
5
+      <change afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
6
+      <change afterPath="$PROJECT_DIR$/.idea/dataSources.xml" afterDir="false" />
7
+      <change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
8
+      <change afterPath="$PROJECT_DIR$/src/main/java/Account.java" afterDir="false" />
9
+      <change afterPath="$PROJECT_DIR$/src/main/java/AccountApp.java" afterDir="false" />
10
+    </list>
11
+    <ignored path="$PROJECT_DIR$/out/" />
12
+    <ignored path="$PROJECT_DIR$/target/" />
13
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
14
+    <option name="SHOW_DIALOG" value="false" />
15
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
16
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
17
+    <option name="LAST_RESOLUTION" value="IGNORE" />
18
+  </component>
19
+  <component name="DatabaseView">
20
+    <option name="SHOW_INTERMEDIATE" value="true" />
21
+    <option name="GROUP_DATA_SOURCES" value="true" />
22
+    <option name="GROUP_SCHEMA" value="true" />
23
+    <option name="GROUP_CONTENTS" value="false" />
24
+    <option name="SORT_POSITIONED" value="false" />
25
+    <option name="SHOW_EMPTY_GROUPS" value="false" />
26
+    <option name="AUTO_SCROLL_FROM_SOURCE" value="false" />
27
+    <option name="HIDDEN_KINDS">
28
+      <set />
29
+    </option>
30
+    <expand>
31
+      <path>
32
+        <item name="Database" type="3277223f:DatabaseStructure$DbRootGroup" />
33
+        <item name="@localhost" type="feb32156:DbDataSourceImpl" />
34
+      </path>
35
+    </expand>
36
+    <select />
37
+  </component>
38
+  <component name="FUSProjectUsageTrigger">
39
+    <session id="-1108601413">
40
+      <usages-collector id="statistics.lifecycle.project">
41
+        <counts>
42
+          <entry key="project.open.time.8" value="1" />
43
+          <entry key="project.opened" value="1" />
44
+        </counts>
45
+      </usages-collector>
46
+      <usages-collector id="statistics.file.types.open">
47
+        <counts>
48
+          <entry key="JAVA" value="2" />
49
+          <entry key="Scratch" value="1" />
50
+          <entry key="XML" value="1" />
51
+        </counts>
52
+      </usages-collector>
53
+      <usages-collector id="statistics.file.types.edit">
54
+        <counts>
55
+          <entry key="JAVA" value="506" />
56
+          <entry key="PLAIN_TEXT" value="14" />
57
+          <entry key="SQL" value="8" />
58
+          <entry key="XML" value="10" />
59
+        </counts>
60
+      </usages-collector>
61
+    </session>
62
+  </component>
63
+  <component name="FileEditorManager">
64
+    <leaf>
65
+      <file pinned="false" current-in-tab="false">
66
+        <entry file="file://$PROJECT_DIR$/pom.xml">
67
+          <provider selected="true" editor-type-id="text-editor">
68
+            <state relative-caret-position="480">
69
+              <caret line="32" selection-start-line="32" selection-end-line="32" />
70
+            </state>
71
+          </provider>
72
+        </entry>
73
+      </file>
74
+      <file pinned="false" current-in-tab="false">
75
+        <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
76
+          <provider selected="true" editor-type-id="text-editor">
77
+            <state relative-caret-position="159">
78
+              <caret line="23" column="25" selection-start-line="23" selection-start-column="25" selection-end-line="23" selection-end-column="25" />
79
+              <folding>
80
+                <element signature="imports" expanded="true" />
81
+                <element signature="e#577#578#0" expanded="true" />
82
+                <element signature="e#609#610#0" expanded="true" />
83
+                <element signature="e#724#725#0" expanded="true" />
84
+                <element signature="e#749#750#0" expanded="true" />
85
+                <element signature="e#780#781#0" expanded="true" />
86
+                <element signature="e#807#808#0" expanded="true" />
87
+                <element signature="e#847#848#0" expanded="true" />
88
+                <element signature="e#879#880#0" expanded="true" />
89
+                <element signature="e#914#915#0" expanded="true" />
90
+                <element signature="e#945#946#0" expanded="true" />
91
+                <element signature="e#993#994#0" expanded="true" />
92
+                <element signature="e#1033#1034#0" expanded="true" />
93
+                <element signature="e#1079#1080#0" expanded="true" />
94
+                <element signature="e#1116#1117#0" expanded="true" />
95
+              </folding>
96
+            </state>
97
+          </provider>
98
+        </entry>
99
+      </file>
100
+      <file pinned="false" current-in-tab="true">
101
+        <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
102
+          <provider selected="true" editor-type-id="text-editor">
103
+            <state relative-caret-position="100">
104
+              <caret line="9" column="54" selection-start-line="9" selection-start-column="54" selection-end-line="9" selection-end-column="54" />
105
+              <folding>
106
+                <element signature="imports" expanded="true" />
107
+              </folding>
108
+            </state>
109
+          </provider>
110
+        </entry>
111
+      </file>
112
+      <file pinned="false" current-in-tab="false">
113
+        <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/3c46b28a-50b3-4b19-a8e9-11b7b846b04d/console.sql">
114
+          <provider selected="true" editor-type-id="text-editor" />
115
+        </entry>
116
+      </file>
117
+    </leaf>
118
+  </component>
119
+  <component name="FileTemplateManagerImpl">
120
+    <option name="RECENT_TEMPLATES">
121
+      <list>
122
+        <option value="Class" />
123
+      </list>
124
+    </option>
125
+  </component>
126
+  <component name="Git.Settings">
127
+    <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
128
+  </component>
129
+  <component name="IdeDocumentHistory">
130
+    <option name="CHANGED_PATHS">
131
+      <list>
132
+        <option value="$PROJECT_DIR$/pom.xml" />
133
+        <option value="$PROJECT_DIR$/src/main/java/Account.java" />
134
+        <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
135
+      </list>
136
+    </option>
137
+  </component>
138
+  <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
139
+  <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
140
+  <component name="JsGulpfileManager">
141
+    <detection-done>true</detection-done>
142
+    <sorting>DEFINITION_ORDER</sorting>
143
+  </component>
144
+  <component name="MavenImportPreferences">
145
+    <option name="importingSettings">
146
+      <MavenImportingSettings>
147
+        <option name="importAutomatically" value="true" />
148
+      </MavenImportingSettings>
149
+    </option>
150
+  </component>
151
+  <component name="ProjectFrameBounds">
152
+    <option name="x" value="-270" />
153
+    <option name="y" value="-1017" />
154
+    <option name="width" value="1430" />
155
+    <option name="height" value="986" />
156
+  </component>
157
+  <component name="ProjectView">
158
+    <navigator proportions="" version="1">
159
+      <foldersAlwaysOnTop value="true" />
160
+    </navigator>
161
+    <panes>
162
+      <pane id="Scope" />
163
+      <pane id="PackagesPane" />
164
+      <pane id="ProjectPane">
165
+        <subPane>
166
+          <expand>
167
+            <path>
168
+              <item name="ormSimpleAccount" type="b2602c69:ProjectViewProjectNode" />
169
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
170
+            </path>
171
+            <path>
172
+              <item name="ormSimpleAccount" type="b2602c69:ProjectViewProjectNode" />
173
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
174
+              <item name="src" type="462c0819:PsiDirectoryNode" />
175
+            </path>
176
+            <path>
177
+              <item name="ormSimpleAccount" type="b2602c69:ProjectViewProjectNode" />
178
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
179
+              <item name="src" type="462c0819:PsiDirectoryNode" />
180
+              <item name="main" type="462c0819:PsiDirectoryNode" />
181
+            </path>
182
+            <path>
183
+              <item name="ormSimpleAccount" type="b2602c69:ProjectViewProjectNode" />
184
+              <item name="ZCW-ORM-SimpleAccount" type="462c0819:PsiDirectoryNode" />
185
+              <item name="src" type="462c0819:PsiDirectoryNode" />
186
+              <item name="main" type="462c0819:PsiDirectoryNode" />
187
+              <item name="java" type="462c0819:PsiDirectoryNode" />
188
+            </path>
189
+          </expand>
190
+          <select />
191
+        </subPane>
192
+      </pane>
193
+    </panes>
194
+  </component>
195
+  <component name="PropertiesComponent">
196
+    <property name="DatabaseDriversLRU" value="mysql" />
197
+    <property name="WebServerToolWindowFactoryState" value="false" />
198
+    <property name="aspect.path.notification.shown" value="true" />
199
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1546829752172" />
200
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
201
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
202
+  </component>
203
+  <component name="RunDashboard">
204
+    <option name="ruleStates">
205
+      <list>
206
+        <RuleState>
207
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
208
+        </RuleState>
209
+        <RuleState>
210
+          <option name="name" value="StatusDashboardGroupingRule" />
211
+        </RuleState>
212
+      </list>
213
+    </option>
214
+  </component>
215
+  <component name="SvnConfiguration">
216
+    <configuration />
217
+  </component>
218
+  <component name="TaskManager">
219
+    <task active="true" id="Default" summary="Default task">
220
+      <changelist id="5201bf50-7c34-4b6d-8010-7ae925bc926d" name="Default Changelist" comment="" />
221
+      <created>1546827200362</created>
222
+      <option name="number" value="Default" />
223
+      <option name="presentableId" value="Default" />
224
+      <updated>1546827200362</updated>
225
+      <workItem from="1546827205936" duration="2418000" />
226
+    </task>
227
+    <servers />
228
+  </component>
229
+  <component name="TimeTrackingManager">
230
+    <option name="totallyTimeSpent" value="2418000" />
231
+  </component>
232
+  <component name="ToolWindowManager">
233
+    <frame x="-270" y="-1017" width="1430" height="986" extended-state="0" />
234
+    <editor active="true" />
235
+    <layout>
236
+      <window_info id="Image Layers" />
237
+      <window_info id="Designer" />
238
+      <window_info id="UI Designer" />
239
+      <window_info id="Capture Tool" />
240
+      <window_info id="Favorites" side_tool="true" />
241
+      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.19524495" />
242
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
243
+      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
244
+      <window_info anchor="bottom" id="Database Changes" weight="0.3295063" />
245
+      <window_info anchor="bottom" id="Version Control" />
246
+      <window_info anchor="bottom" id="Terminal" />
247
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
248
+      <window_info anchor="bottom" id="Message" order="0" />
249
+      <window_info anchor="bottom" id="Find" order="1" />
250
+      <window_info anchor="bottom" id="Run" order="2" />
251
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
252
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
253
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
254
+      <window_info anchor="bottom" id="TODO" order="6" />
255
+      <window_info anchor="right" id="Palette" />
256
+      <window_info anchor="right" id="Theme Preview" />
257
+      <window_info anchor="right" id="Capture Analysis" />
258
+      <window_info anchor="right" id="Palette&#9;" />
259
+      <window_info anchor="right" id="Database" visible="true" weight="0.25792506" />
260
+      <window_info anchor="right" id="Maven Projects" />
261
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
262
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
263
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
264
+    </layout>
265
+  </component>
266
+  <component name="TypeScriptGeneratedFilesManager">
267
+    <option name="version" value="1" />
268
+  </component>
269
+  <component name="VcsContentAnnotationSettings">
270
+    <option name="myLimit" value="2678400000" />
271
+  </component>
272
+  <component name="editorHistoryManager">
273
+    <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/3c46b28a-50b3-4b19-a8e9-11b7b846b04d/console.sql">
274
+      <provider selected="true" editor-type-id="text-editor" />
275
+    </entry>
276
+    <entry file="file://$PROJECT_DIR$/pom.xml">
277
+      <provider selected="true" editor-type-id="text-editor">
278
+        <state relative-caret-position="480">
279
+          <caret line="32" selection-start-line="32" selection-end-line="32" />
280
+        </state>
281
+      </provider>
282
+    </entry>
283
+    <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
284
+      <provider selected="true" editor-type-id="text-editor">
285
+        <state relative-caret-position="159">
286
+          <caret line="23" column="25" selection-start-line="23" selection-start-column="25" selection-end-line="23" selection-end-column="25" />
287
+          <folding>
288
+            <element signature="imports" expanded="true" />
289
+            <element signature="e#577#578#0" expanded="true" />
290
+            <element signature="e#609#610#0" expanded="true" />
291
+            <element signature="e#724#725#0" expanded="true" />
292
+            <element signature="e#749#750#0" expanded="true" />
293
+            <element signature="e#780#781#0" expanded="true" />
294
+            <element signature="e#807#808#0" expanded="true" />
295
+            <element signature="e#847#848#0" expanded="true" />
296
+            <element signature="e#879#880#0" expanded="true" />
297
+            <element signature="e#914#915#0" expanded="true" />
298
+            <element signature="e#945#946#0" expanded="true" />
299
+            <element signature="e#993#994#0" expanded="true" />
300
+            <element signature="e#1033#1034#0" expanded="true" />
301
+            <element signature="e#1079#1080#0" expanded="true" />
302
+            <element signature="e#1116#1117#0" expanded="true" />
303
+          </folding>
304
+        </state>
305
+      </provider>
306
+    </entry>
307
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
308
+      <provider selected="true" editor-type-id="text-editor">
309
+        <state relative-caret-position="100">
310
+          <caret line="9" column="54" selection-start-line="9" selection-start-column="54" selection-end-line="9" selection-end-column="54" />
311
+          <folding>
312
+            <element signature="imports" expanded="true" />
313
+          </folding>
314
+        </state>
315
+      </provider>
316
+    </entry>
317
+  </component>
318
+</project>

+ 2
- 0
ZCW-ORM-SimpleAccount.iml Datei anzeigen

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

+ 36
- 0
pom.xml Datei anzeigen

@@ -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>com.zipcodewilmington</groupId>
8
+    <artifactId>ormSimpleAccount</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
+
35
+
36
+</project>

+ 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
+
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
+    public Account() {
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
+}

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

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