Procházet zdrojové kódy

CR/CRUD implemented

Jarrett Samuels před 6 roky
rodič
revize
5dbe5e307e

+ 13
- 0
ormsimpleaccount/.idea/compiler.xml Zobrazit soubor

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

+ 4
- 0
ormsimpleaccount/.idea/encodings.xml Zobrazit soubor

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
4
+</project>

+ 14
- 0
ormsimpleaccount/.idea/misc.xml Zobrazit soubor

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

+ 348
- 0
ormsimpleaccount/.idea/workspace.xml Zobrazit soubor

@@ -0,0 +1,348 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ChangeListManager">
4
+    <list default="true" id="29f9e802-3028-4641-b113-231e3ff56c52" name="Default Changelist" comment="" />
5
+    <ignored path="$PROJECT_DIR$/out/" />
6
+    <ignored path="$PROJECT_DIR$/target/" />
7
+    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
8
+    <option name="SHOW_DIALOG" value="false" />
9
+    <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
+    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
+    <option name="LAST_RESOLUTION" value="IGNORE" />
12
+  </component>
13
+  <component name="DockManager">
14
+    <window id="1">
15
+      <content type="file-editors">
16
+        <state>
17
+          <leaf>
18
+            <file pinned="false" current-in-tab="true">
19
+              <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
20
+                <provider selected="true" editor-type-id="text-editor">
21
+                  <state relative-caret-position="308">
22
+                    <caret line="33" column="9" lean-forward="true" selection-start-line="33" selection-start-column="9" selection-end-line="33" selection-end-column="9" />
23
+                    <folding>
24
+                      <element signature="imports" expanded="true" />
25
+                      <element signature="e#1154#1155#0" expanded="true" />
26
+                      <element signature="e#1193#1194#0" expanded="true" />
27
+                    </folding>
28
+                  </state>
29
+                </provider>
30
+              </entry>
31
+            </file>
32
+          </leaf>
33
+        </state>
34
+      </content>
35
+    </window>
36
+  </component>
37
+  <component name="FileEditorManager">
38
+    <leaf>
39
+      <file pinned="false" current-in-tab="true">
40
+        <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
41
+          <provider selected="true" editor-type-id="text-editor">
42
+            <state relative-caret-position="437">
43
+              <caret line="19" lean-forward="true" selection-start-line="19" selection-end-line="19" />
44
+              <folding>
45
+                <element signature="imports" expanded="true" />
46
+              </folding>
47
+            </state>
48
+          </provider>
49
+        </entry>
50
+      </file>
51
+    </leaf>
52
+  </component>
53
+  <component name="FileTemplateManagerImpl">
54
+    <option name="RECENT_TEMPLATES">
55
+      <list>
56
+        <option value="Class" />
57
+      </list>
58
+    </option>
59
+  </component>
60
+  <component name="IdeDocumentHistory">
61
+    <option name="CHANGED_PATHS">
62
+      <list>
63
+        <option value="$PROJECT_DIR$/src/main/java/Account.java" />
64
+        <option value="$PROJECT_DIR$/pom.xml" />
65
+        <option value="$PROJECT_DIR$/src/main/java/AccountApp.java" />
66
+      </list>
67
+    </option>
68
+  </component>
69
+  <component name="MavenImportPreferences">
70
+    <option name="importingSettings">
71
+      <MavenImportingSettings>
72
+        <option name="importAutomatically" value="true" />
73
+      </MavenImportingSettings>
74
+    </option>
75
+  </component>
76
+  <component name="ProjectFrameBounds">
77
+    <option name="x" value="720" />
78
+    <option name="y" value="23" />
79
+    <option name="width" value="720" />
80
+    <option name="height" value="822" />
81
+  </component>
82
+  <component name="ProjectView">
83
+    <navigator proportions="" version="1">
84
+      <foldersAlwaysOnTop value="true" />
85
+    </navigator>
86
+    <panes>
87
+      <pane id="PackagesPane" />
88
+      <pane id="Scope" />
89
+      <pane id="ProjectPane">
90
+        <subPane>
91
+          <expand>
92
+            <path>
93
+              <item name="ormsimpleaccount" type="b2602c69:ProjectViewProjectNode" />
94
+              <item name="ormsimpleaccount" type="462c0819:PsiDirectoryNode" />
95
+            </path>
96
+            <path>
97
+              <item name="ormsimpleaccount" type="b2602c69:ProjectViewProjectNode" />
98
+              <item name="ormsimpleaccount" type="462c0819:PsiDirectoryNode" />
99
+              <item name="src" type="462c0819:PsiDirectoryNode" />
100
+            </path>
101
+            <path>
102
+              <item name="ormsimpleaccount" type="b2602c69:ProjectViewProjectNode" />
103
+              <item name="ormsimpleaccount" type="462c0819:PsiDirectoryNode" />
104
+              <item name="src" type="462c0819:PsiDirectoryNode" />
105
+              <item name="main" type="462c0819:PsiDirectoryNode" />
106
+            </path>
107
+            <path>
108
+              <item name="ormsimpleaccount" type="b2602c69:ProjectViewProjectNode" />
109
+              <item name="ormsimpleaccount" type="462c0819:PsiDirectoryNode" />
110
+              <item name="src" type="462c0819:PsiDirectoryNode" />
111
+              <item name="test" type="462c0819:PsiDirectoryNode" />
112
+            </path>
113
+          </expand>
114
+          <select />
115
+        </subPane>
116
+      </pane>
117
+    </panes>
118
+  </component>
119
+  <component name="PropertiesComponent">
120
+    <property name="WebServerToolWindowFactoryState" value="false" />
121
+    <property name="aspect.path.notification.shown" value="true" />
122
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1543122267746" />
123
+    <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
124
+    <property name="nodejs_npm_path_reset_for_default_project" value="true" />
125
+    <property name="project.structure.last.edited" value="Modules" />
126
+    <property name="project.structure.proportion" value="0.0" />
127
+    <property name="project.structure.side.proportion" value="0.0" />
128
+  </component>
129
+  <component name="RunDashboard">
130
+    <option name="ruleStates">
131
+      <list>
132
+        <RuleState>
133
+          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
134
+        </RuleState>
135
+        <RuleState>
136
+          <option name="name" value="StatusDashboardGroupingRule" />
137
+        </RuleState>
138
+      </list>
139
+    </option>
140
+  </component>
141
+  <component name="RunManager">
142
+    <configuration name="AccountApp" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
143
+      <option name="MAIN_CLASS_NAME" value="AccountApp" />
144
+      <module name="ormsimpleaccount" />
145
+      <method v="2">
146
+        <option name="Make" enabled="true" />
147
+      </method>
148
+    </configuration>
149
+    <recent_temporary>
150
+      <list>
151
+        <item itemvalue="Application.AccountApp" />
152
+      </list>
153
+    </recent_temporary>
154
+  </component>
155
+  <component name="SvnConfiguration">
156
+    <configuration />
157
+  </component>
158
+  <component name="TaskManager">
159
+    <task active="true" id="Default" summary="Default task">
160
+      <changelist id="29f9e802-3028-4641-b113-231e3ff56c52" name="Default Changelist" comment="" />
161
+      <created>1543114478395</created>
162
+      <option name="number" value="Default" />
163
+      <option name="presentableId" value="Default" />
164
+      <updated>1543114478395</updated>
165
+      <workItem from="1543114483896" duration="4581000" />
166
+    </task>
167
+    <servers />
168
+  </component>
169
+  <component name="TimeTrackingManager">
170
+    <option name="totallyTimeSpent" value="4581000" />
171
+  </component>
172
+  <component name="ToolWindowManager">
173
+    <frame x="720" y="23" width="720" height="822" extended-state="0" />
174
+    <editor active="true" />
175
+    <layout>
176
+      <window_info id="Image Layers" />
177
+      <window_info id="Designer" />
178
+      <window_info id="UI Designer" />
179
+      <window_info id="Capture Tool" />
180
+      <window_info id="Favorites" side_tool="true" />
181
+      <window_info content_ui="combo" id="Project" order="0" weight="0.24934153" />
182
+      <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
183
+      <window_info anchor="bottom" id="Messages" weight="0.32991013" />
184
+      <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
185
+      <window_info anchor="bottom" id="Database Changes" />
186
+      <window_info anchor="bottom" id="Version Control" />
187
+      <window_info anchor="bottom" id="Terminal" />
188
+      <window_info anchor="bottom" id="Event Log" side_tool="true" />
189
+      <window_info anchor="bottom" id="Message" order="0" />
190
+      <window_info anchor="bottom" id="Find" order="1" />
191
+      <window_info anchor="bottom" id="Run" order="2" weight="0.46084723" />
192
+      <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
193
+      <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
194
+      <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
195
+      <window_info anchor="bottom" id="TODO" order="6" />
196
+      <window_info anchor="right" id="Palette" />
197
+      <window_info anchor="right" id="Theme Preview" />
198
+      <window_info anchor="right" id="Maven" />
199
+      <window_info anchor="right" id="Capture Analysis" />
200
+      <window_info anchor="right" id="Palette&#9;" />
201
+      <window_info anchor="right" id="Database" />
202
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
203
+      <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
204
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
205
+    </layout>
206
+    <layout-to-restore>
207
+      <window_info id="Image Layers" order="0" />
208
+      <window_info id="Designer" order="1" />
209
+      <window_info id="UI Designer" order="2" />
210
+      <window_info id="Capture Tool" order="3" />
211
+      <window_info id="Favorites" order="4" side_tool="true" />
212
+      <window_info content_ui="combo" id="Project" order="5" visible="true" weight="0.24934153" />
213
+      <window_info id="Structure" order="6" side_tool="true" weight="0.25" />
214
+      <window_info anchor="bottom" id="Docker" order="0" show_stripe_button="false" />
215
+      <window_info anchor="bottom" id="Version Control" order="1" />
216
+      <window_info anchor="bottom" id="Terminal" order="2" />
217
+      <window_info anchor="bottom" id="Database Changes" order="3" />
218
+      <window_info anchor="bottom" id="Event Log" order="4" side_tool="true" />
219
+      <window_info anchor="bottom" id="Messages" order="5" weight="0.32991013" />
220
+      <window_info anchor="bottom" id="Message" order="6" />
221
+      <window_info anchor="bottom" id="Find" order="7" />
222
+      <window_info active="true" anchor="bottom" id="Run" order="8" visible="true" weight="0.46084723" />
223
+      <window_info anchor="bottom" id="Debug" order="9" weight="0.4" />
224
+      <window_info anchor="bottom" id="Cvs" order="10" weight="0.25" />
225
+      <window_info anchor="bottom" id="Inspection" order="11" weight="0.4" />
226
+      <window_info anchor="bottom" id="TODO" order="12" />
227
+      <window_info anchor="right" id="Palette" order="0" />
228
+      <window_info anchor="right" id="Database" order="1" />
229
+      <window_info anchor="right" id="Theme Preview" order="2" />
230
+      <window_info anchor="right" id="Capture Analysis" order="3" />
231
+      <window_info anchor="right" id="Palette&#9;" order="4" />
232
+      <window_info anchor="right" id="Maven" order="5" />
233
+      <window_info anchor="right" id="Commander" internal_type="SLIDING" order="6" type="SLIDING" weight="0.4" />
234
+      <window_info anchor="right" id="Ant Build" order="7" weight="0.25" />
235
+      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="8" weight="0.25" />
236
+    </layout-to-restore>
237
+  </component>
238
+  <component name="TypeScriptGeneratedFilesManager">
239
+    <option name="version" value="1" />
240
+  </component>
241
+  <component name="editorHistoryManager">
242
+    <entry file="file://$PROJECT_DIR$/pom.xml">
243
+      <provider selected="true" editor-type-id="text-editor">
244
+        <state relative-caret-position="156">
245
+          <caret line="15" column="39" selection-start-line="15" selection-start-column="39" selection-end-line="15" selection-end-column="39" />
246
+        </state>
247
+      </provider>
248
+    </entry>
249
+    <entry file="file://$PROJECT_DIR$/src/main/java/Account.java">
250
+      <provider selected="true" editor-type-id="text-editor">
251
+        <state relative-caret-position="308">
252
+          <caret line="33" column="9" lean-forward="true" selection-start-line="33" selection-start-column="9" selection-end-line="33" selection-end-column="9" />
253
+          <folding>
254
+            <element signature="imports" expanded="true" />
255
+            <element signature="e#1154#1155#0" expanded="true" />
256
+            <element signature="e#1193#1194#0" expanded="true" />
257
+          </folding>
258
+        </state>
259
+      </provider>
260
+    </entry>
261
+    <entry file="file://$PROJECT_DIR$/src/main/java/AccountApp.java">
262
+      <provider selected="true" editor-type-id="text-editor">
263
+        <state relative-caret-position="437">
264
+          <caret line="19" lean-forward="true" selection-start-line="19" selection-end-line="19" />
265
+          <folding>
266
+            <element signature="imports" expanded="true" />
267
+          </folding>
268
+        </state>
269
+      </provider>
270
+    </entry>
271
+  </component>
272
+  <component name="masterDetails">
273
+    <states>
274
+      <state key="ArtifactsStructureConfigurable.UI">
275
+        <settings>
276
+          <artifact-editor />
277
+          <splitter-proportions>
278
+            <option name="proportions">
279
+              <list>
280
+                <option value="0.2" />
281
+              </list>
282
+            </option>
283
+          </splitter-proportions>
284
+        </settings>
285
+      </state>
286
+      <state key="FacetStructureConfigurable.UI">
287
+        <settings>
288
+          <last-edited>No facets are configured</last-edited>
289
+          <splitter-proportions>
290
+            <option name="proportions">
291
+              <list>
292
+                <option value="0.2" />
293
+              </list>
294
+            </option>
295
+          </splitter-proportions>
296
+        </settings>
297
+      </state>
298
+      <state key="GlobalLibrariesConfigurable.UI">
299
+        <settings>
300
+          <splitter-proportions>
301
+            <option name="proportions">
302
+              <list>
303
+                <option value="0.2" />
304
+              </list>
305
+            </option>
306
+          </splitter-proportions>
307
+        </settings>
308
+      </state>
309
+      <state key="JdkListConfigurable.UI">
310
+        <settings>
311
+          <last-edited>1.8</last-edited>
312
+          <splitter-proportions>
313
+            <option name="proportions">
314
+              <list>
315
+                <option value="0.2" />
316
+              </list>
317
+            </option>
318
+          </splitter-proportions>
319
+        </settings>
320
+      </state>
321
+      <state key="ModuleStructureConfigurable.UI">
322
+        <settings>
323
+          <last-edited>ormsimpleaccount</last-edited>
324
+          <splitter-proportions>
325
+            <option name="proportions">
326
+              <list>
327
+                <option value="0.2" />
328
+                <option value="0.6" />
329
+              </list>
330
+            </option>
331
+          </splitter-proportions>
332
+        </settings>
333
+      </state>
334
+      <state key="ProjectLibrariesConfigurable.UI">
335
+        <settings>
336
+          <last-edited>Maven: com.j256.ormlite:ormlite-core:4.48</last-edited>
337
+          <splitter-proportions>
338
+            <option name="proportions">
339
+              <list>
340
+                <option value="0.2" />
341
+              </list>
342
+            </option>
343
+          </splitter-proportions>
344
+        </settings>
345
+      </state>
346
+    </states>
347
+  </component>
348
+</project>

+ 2
- 0
ormsimpleaccount/ormsimpleaccount.iml Zobrazit soubor

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

+ 36
- 0
ormsimpleaccount/pom.xml Zobrazit soubor

@@ -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</version>
10
+
11
+    <dependencies>
12
+
13
+        <!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-core -->
14
+        <dependency>
15
+            <groupId>com.j256.ormlite</groupId>
16
+            <artifactId>ormlite-core</artifactId>
17
+            <version>4.48</version>
18
+        </dependency>
19
+
20
+        <!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-jdbc -->
21
+        <dependency>
22
+            <groupId>com.j256.ormlite</groupId>
23
+            <artifactId>ormlite-jdbc</artifactId>
24
+            <version>4.48</version>
25
+        </dependency>
26
+
27
+        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
28
+        <dependency>
29
+            <groupId>mysql</groupId>
30
+            <artifactId>mysql-connector-java</artifactId>
31
+            <version>8.0.13</version>
32
+        </dependency>
33
+
34
+    </dependencies>
35
+
36
+</project>

+ 64
- 0
ormsimpleaccount/src/main/java/Account.java Zobrazit soubor

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

+ 139
- 0
ormsimpleaccount/src/main/java/AccountApp.java Zobrazit soubor

@@ -0,0 +1,139 @@
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.util.Scanner;
7
+
8
+public class AccountApp {
9
+
10
+    Scanner in = new Scanner(System.in);
11
+    // we are using a MySQl database
12
+    private final static String DATABASE_URL = "jdbc:mysql://localhost:3306/orm_lab?useUnicode=true";
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, "root", "kuchikibyakuya");
26
+            // setup our  DAOs
27
+            setupDao(connectionSource);
28
+            // Begin control
29
+
30
+            boolean loop = true;
31
+
32
+            while (loop){
33
+
34
+                System.out.println
35
+                        ("Welcome to the account DB. What would you like to do? \n" +
36
+                        "1. Create a new Entry \n " +
37
+                        "2. Print Current Entries \n " +
38
+                        "3. Update existing entries \n " +
39
+                        "4. Delete existing entries \n" +
40
+                                "5. Exit \n");
41
+                int input = in.nextInt();
42
+
43
+                switch (input) {
44
+                    case 1: newEntry();
45
+                            break;
46
+                    case 2: printTable();
47
+                            break;
48
+                    case 3: updateEntries();
49
+                            break;
50
+                    case 4: deleteEntries();
51
+                            break;
52
+                    default: loop = false;
53
+                            break;
54
+
55
+                }
56
+
57
+            }
58
+
59
+
60
+            //End control
61
+        } finally {
62
+            // destroy the data source which should close underlying connections
63
+            if (connectionSource != null) {
64
+                connectionSource.close();
65
+            }
66
+        }
67
+    }
68
+
69
+    /**
70
+     * Read and write some example data.
71
+     */
72
+
73
+    public void newEntry() throws Exception {
74
+
75
+        //Grab name
76
+        String input = "";
77
+        System.out.println("Please enter a name");
78
+        input = in.nextLine();
79
+
80
+        //Setup new account object/entry using name input
81
+        Account temp = new Account(input);
82
+
83
+        //Grab Password
84
+        System.out.println("Now Please enter a password");
85
+        input = in.nextLine();
86
+
87
+        //Append password to temp account
88
+        temp.setPassword(input);
89
+
90
+        //Finish up adding entry
91
+        accountDao.create(temp);
92
+        accountDao.update(temp);
93
+
94
+    }
95
+
96
+    public void printTable() throws Exception {
97
+
98
+        System.out.println(accountDao.queryRaw("SELECT * FROM account;"));
99
+
100
+    }
101
+
102
+    public void updateEntries() throws Exception {
103
+
104
+
105
+
106
+    }
107
+
108
+    public void deleteEntries () {
109
+
110
+
111
+
112
+    }
113
+
114
+    private void processData() throws Exception {
115
+        // create an instance of Account
116
+        String name = "Jim Coakley";
117
+        Account account = new Account(name);
118
+
119
+        // persist the account object to the database
120
+        accountDao.create(account);
121
+        //int id = account.getId();
122
+        //System.out.println(id);
123
+        // assign a password
124
+        account.setPassword("_secret");
125
+        // update the database after changing the object
126
+        accountDao.update(account);
127
+        // delete the account
128
+        //accountDao.deleteById(id);
129
+    }
130
+
131
+    /**
132
+     * Setup our  DAOs
133
+     */
134
+    private void setupDao(ConnectionSource connectionSource) throws Exception {
135
+
136
+        accountDao = DaoManager.createDao(connectionSource, Account.class);
137
+
138
+    }
139
+}

binární
ormsimpleaccount/target/classes/Account.class Zobrazit soubor


binární
ormsimpleaccount/target/classes/AccountApp.class Zobrazit soubor