Froilan Miranda 6 лет назад
Родитель
Сommit
f2c0a95836
1 измененных файлов: 11 добавлений и 7 удалений
  1. 11
    7
      README.md

+ 11
- 7
README.md Просмотреть файл

1
 # Part 1 - Create MySQL Database
1
 # Part 1 - Create MySQL Database
2
 1. Start MySQL from console
2
 1. Start MySQL from console
3
-2. Create a new Database named 'orm-lab'
3
+2. Create a new Database named 'orm_lab'
4
 3. Inside that database create a new table name 'account'
4
 3. Inside that database create a new table name 'account'
5
 4. the schema should be as folllow
5
 4. the schema should be as folllow
6
 
6
 
14
 
14
 
15
 ## Adding dependencies
15
 ## Adding dependencies
16
 1 Create a new Java Maven project
16
 1 Create a new Java Maven project
17
+
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
 2 Update the pom.xml file by adding the following dependencies. These are the dependencies for the ORM library we will be using.
18
 
19
 
19
 ```
20
 ```
48
 Create a new Java class name 'Account'
49
 Create a new Java class name 'Account'
49
 
50
 
50
 ```
51
 ```
51
-
52
 import com.j256.ormlite.field.DatabaseField;
52
 import com.j256.ormlite.field.DatabaseField;
53
 import com.j256.ormlite.table.DatabaseTable;
53
 import com.j256.ormlite.table.DatabaseTable;
54
 
54
 
55
 @DatabaseTable(tableName = "account")
55
 @DatabaseTable(tableName = "account")
56
 public class Account {
56
 public class Account {
57
 
57
 
58
-    // for QueryBuilder to be able to find the fields
59
     public static final String NAME_FIELD_NAME = "name";
58
     public static final String NAME_FIELD_NAME = "name";
60
     public static final String PASSWORD_FIELD_NAME = "password";
59
     public static final String PASSWORD_FIELD_NAME = "password";
61
 
60
 
62
     @DatabaseField(columnName = "id", generatedId = true)
61
     @DatabaseField(columnName = "id", generatedId = true)
63
     private int id;
62
     private int id;
64
 
63
 
65
-    @DatabaseField(columnName = NAME_FIELD_NAME, canBeNull = false)
64
+    @DatabaseField(columnName = "name", canBeNull = false)
66
     private String name;
65
     private String name;
67
 
66
 
68
-    @DatabaseField(columnName = PASSWORD_FIELD_NAME)
67
+    @DatabaseField(columnName = "password")
69
     private String password;
68
     private String password;
70
 
69
 
71
     Account() {
70
     Account() {
122
 Create a Java class name 'AccountApp'
121
 Create a Java class name 'AccountApp'
123
 
122
 
124
 ```
123
 ```
124
+import com.j256.ormlite.dao.Dao;
125
+import com.j256.ormlite.dao.DaoManager;
126
+import com.j256.ormlite.jdbc.JdbcConnectionSource;
127
+import com.j256.ormlite.support.ConnectionSource;
128
+
125
 public class AccountApp {
129
 public class AccountApp {
126
 
130
 
127
     // we are using a MySQl database
131
     // we are using a MySQl database
128
-    private final static String DATABASE_URL = "jdbc:mysql://localhost:3306/orm-lab?useUnicode=true";
132
+    private final static String DATABASE_URL = "jdbc:mysql://localhost:3306/orm_lab?useUnicode=true";
129
 
133
 
130
     private Dao<Account, Integer> accountDao;
134
     private Dao<Account, Integer> accountDao;
131
 
135
 
183
     }
187
     }
184
 }
188
 }
185
 ```
189
 ```
186
-Some of the things to take notice of are the objects that libraries offer use:
190
+Some of the things in this class to take notice are the objects that the imported libraries offer us:
187
 
191
 
188
 * JdbcConnectionSource from the JDBC library
192
 * JdbcConnectionSource from the JDBC library
189
 * Dao and DaoManager from the OrmLite
193
 * Dao and DaoManager from the OrmLite