20220222 º¹½À
< ÆÐÅ°Áö >
Model ( µ¥ÀÌÅͺ£À̽º X, ÆÄÀÏ )
View ( UI, html ȸ鱸¼º )
Controller ( java ±â´É )
add_model
add_view
add_controller
< ÇÔ¼ö >
static void addRead() {
}
static void addCreate() {
}
static void addUpdate() {
}
static void addDelete() {
}
static void addSearch() {
}
static void addMenu() {
}
< ÆÄÀÏ >
address.txt
< ¹Ì´ÏÇÁ·ÎÁ§Æ® > -- >> < À¥(ÆÄÀÏÀÔÃâ·Â) html, jsp(ÄíÅ°, ¼¼¼Ç) >
-- >> < JSP + DB > -- >> < spring >
¹®¹ý
º¯¼ö
ÇÔ¼ö
Á¦¾î¹®(Á¶°Ç¹®, ¹Ýº¹¹®)
¹è¿
ÆÄÀÏ
DB
#oracle(16G), mysql(4G)
mysql -u root -p
show databases;
create database 'DB';
use 'DB';
show tables;
select*from 'TABLE';
CREATE TABLE IF NOT EXISTS `address` (
`idx` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL COMMENT 'À̸§',
`phone` varchar(20) NOT NULL COMMENT 'ÀüȹøÈ£',
`email` varchar(50) NOT NULL COMMENT 'À̸ÞÀÏ',
`address` varchar(50) NOT NULL COMMENT 'ÁÖ¼Ò',
`reg_date` datetime NOT NULL COMMENT 'µî·ÏÀÏ',
PRIMARY KEY (`idx`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='ÁÖ¼Ò·Ï';
INSERT INTO `address` (`idx`, `name`, `phone`, `email`, `address`,`reg_date`)
VALUES (1, 'À̼º¿ø', '010-', 'master@jslweb.izerone.co.kr','ÀüÁÖ½Ã','2012-06-12 22:23:01');
¹Ì´ÏÇÁ·ÎÁ§Æ® 2ÀÏÂ÷
package add.addView;
import java.util.*;
import java.io.*;
public class AddView {
// p249(method)
static void addRead() { // p904 (ÆÄÀÏÀÔÃâ·Â) p414 (¿¹¿Üó¸®)(»ó¼Ó)
String fname="address.txt";
try {
FileReader fr=new FileReader(fname);
BufferedReader br=new BufferedReader(fr);
String line="";
for (int i = 0; ( line= br.readLine() ) != null; i++) {
System.out.println(line);
}
br.close(); // ¿·ÁÀÖ´Â FileÀ» ²À ´Ù½Ã ´Ý¾ÆÁÖ±â
}catch(IOException e){
System.out.println("¿¡·¯¹ß»ý");
}
}
static void addCreate() {
System.out.println("creat!!");
String fname="address.txt";
try {
FileWriter fr=new FileWriter(fname);
BufferedWriter br=new BufferedWriter(fr);
String line="";
for (int i = 0; ( line= br.readLine() ) != null; i++) {
System.out.println(line);
}
br.close();
}catch(IOException e){
System.out.println("¿¡·¯¹ß»ý");
}
}
static void addUpdate() {
System.out.println("update!!");
}
static void addDelete() {
System.out.println("delete!!");
}
static void addSearch() {
System.out.println("search!!");
}
static void addMenu() {
//p36 (printf)
System.out.println("< ¹Ì´Ï ÇÁ·Î±×·¥ À̸§ >");
System.out.println("1. ÁÖ¼ÒÃâ·Â");
System.out.println("2. ÁÖ¼Òµî·Ï");
System.out.println("3. ÁÖ¼Ò»èÁ¦");
System.out.println("4. ÁÖ¼Ò¼öÁ¤");
System.out.println("5. ÁÖ¼Ò°Ë»ö");
System.out.println("6. Á¾·á");
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
addMenu();
System.out.println("-¹øÈ£¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.-");
String select=sc.nextLine();
switch (select) {
case "1":
addRead();
break;
case "2":
addCreate();
break;
case "3":
addUpdate();
break;
case "4":
addDelete();
break;
case "5":
addSearch();
break;
case "6":
System.out.println("Á¾·á");
break;
default:
break;
}
/*
addMenu();
addRead(); 1
addCreate(); 2
addUpdate(); 3
addDelete(); 4
addSearch(); 5
*/
}
}