ソースを参照

update readme

Froilan Miranda 6 年 前
コミット
db10b2b568
共有1 個のファイルを変更した16 個の追加6 個の削除を含む
  1. 16
    6
      README.md

+ 16
- 6
README.md ファイルの表示

@@ -10,11 +10,12 @@
10 10
 		*  password VARCHAR(20)
11 11
 		*  PRIMARY KEY = id
12 12
 
13
-# PART 2 - CREATE JAVA APP
13
+# PART 2 - Create Java App
14 14
 
15 15
 ## Adding dependencies
16 16
 1 Create a new Java Maven project
17
-2 Update the pom.xml file by adding the following dependencies
17
+2 Update the pom.xml file by adding the following dependencies. These are the dependencies for the ORM library we will be using.
18
+
18 19
 ```
19 20
         <!-- https://mvnrepository.com/artifact/com.j256.ormlite/ormlite-core -->
20 21
         <dependency>
@@ -29,10 +30,10 @@
29 30
             <artifactId>ormlite-jdbc</artifactId>
30 31
             <version>4.48</version>
31 32
         </dependency>
32
-        ```
33
-These are the dependencies for the ORM library we will be using
33
+```
34
+
34 35
 
35
-3 Then also add the following
36
+3 Then also add the following. This is a dependency that allows us to connect our Java code to MySql
36 37
 
37 38
 ```
38 39
         <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
@@ -114,6 +115,8 @@ public class Account {
114 115
     }
115 116
 }
116 117
 ```
118
+The things to notice here are the annotations. These annotations tell OrmLite how to relate our Java Objects to the records in MySQL
119
+
117 120
 ## Implement the ORM
118 121
 
119 122
 Create a Java class name 'AccountApp'
@@ -135,7 +138,7 @@ public class AccountApp {
135 138
         ConnectionSource connectionSource = null;
136 139
         try {
137 140
             // create our data-source for the database
138
-            connectionSource = new JdbcConnectionSource(DATABASE_URL, "root", "");
141
+            connectionSource = new JdbcConnectionSource(DATABASE_URL, YOURUSERNAME, YOURPASSWORD);
139 142
             // setup our  DAOs
140 143
             setupDao(connectionSource);
141 144
             // read, write and delete some data
@@ -180,6 +183,12 @@ public class AccountApp {
180 183
     }
181 184
 }
182 185
 ```
186
+Some of the things to take notice of are the objects that libraries offer use:
187
+
188
+* JdbcConnectionSource from the JDBC library
189
+* Dao and DaoManager from the OrmLite
190
+
191
+! Links to the above APIs are listed below
183 192
 
184 193
 Now if we run this we should see some info in the console of IntelliJ telling us that the program ran ok. And if we look over to MySQL we can query the table and see that our code has create and updated a record in out database
185 194
 
@@ -194,4 +203,5 @@ The program this far only runs through a few lines of code before it exits. Upgr
194 203
 ### References
195 204
 * [OrmLite core API](http://ormlite.com/javadoc/ormlite-core/)
196 205
 * [OrmLite JDBC](http://ormlite.com/javadoc/ormlite-jdbc/)
206
+* [JdbcConnectionSource](http://ormlite.com/javadoc/ormlite-jdbc/com/j256/ormlite/jdbc/JdbcConnectionSource.html)
197 207
 * [What is CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete)