SlideShare a Scribd company logo
1 of 47
영화 예매’만' 프로그램 DB 설계 
0901289 최명근 
1101131 서진영 
1101196 이성광 
1301131 방소영 
1301243 전유진 
1
목 차 
1. 프로그램 설명 
2. DB 설계 
3. 프로그램 – DB 연결 
4. 결과물 
5. 연동하면서 어려웠던 점 
6. 각 조원의 역할은? 
2
1. 프로그램 설명 
로그인 - 회원 가입 
3
3-1. 프로그램 
4 
메인 - 영화선택창
3-1. 프로그램 
5 
매수 - 좌석선택창
3-1. 프로그램 
간식 주문 – 기념품 주문 창 
6
3-1. 프로그램 
계산 창 
7
2. DB 설계 
회원제로 관리되는 영화 예매 프로그램이다. 
프로그램을 시작하여 예매 버튼을 누르면 영화를 선택할 수 있다. 상영관은 각 영 
화마다 정해져 있다. 상영일정 역시 정해져 있어서 고르지 않는다. 영화 선택 후, 영 
화 관람 인원 수 (예매할 티켓의 매수)를 정해야 한다. 정한 인원 수 만큼 예매가 가 
능한 좌석을 선택할 수 있다. 
영화 종류/좌석 선택 이후, 간식(팝콘과 음료)과 기념품을 구매할 수 있다. 구매하 
지 않아도 된다. 간식(팝콘과 음료)과 종류와 개수를 선택할 수 있다. 
마지막으로 고객은 결제 방법(3가지)을 선택한다. 결제 완료 이후, 고객은 결제된 
내용을 다시 확인이 가능하다. 
/* 참고 사항 */ 
회원가입 할 때 아이디, 비밀번호, 이름, 전화번호정보가 필요하다. 
좌석은 한번에 최대 4자리 씩만 선택할 수 있다. 
8
회원제로 관리되는 영화 예매 프로그램이다. 
프로그램을 시작하여 예매 버튼을 누르면 영화를 선택할 수 있다. 상영관은 각 영 
화마다 정해져 있다. 상영일정 역시 정해져 있어서 고르지 않는다. 영화 선택 후, 영 
화 관람 인원 수 (예매할 티켓의 매수)를 정해야 한다. 정한 인원 수 만큼 예매가 가 
능한 좌석을 선택할 수 있다. 
영화 종류/좌석 선택 이후, 간식(팝콘과 음료)과 기념품을 구매할 수 있다. 구매하 
지 않아도 된다. 간식(팝콘과 음료)과 기념품은 종류와 개수를 선택할 수 있다. 
마지막으로 고객은 결제 방법(3가지)을 선택한다. 결제 완료 이후, 고객은 결제된 
내용을 다시 확인이 가능하다. 
/* 참고 사항 */ 
회원가입 할 때 아이디, 비밀번호, 이름, 전화번호정보가 필요하다. 
좌석은 한번에 최대 4자리 씩만 선택할 수 있다. 
9
개체 명 속성 
# : primary key 
회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 
결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자 
예매한 티켓번호와 수량, 주문한 간식/기념품번호와 수량 
티켓 #티켓번호, 언제, 어떤 영화, 어디서, 좌석번호, 가격 
영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 
상영관 #상영관번호, 총 좌석 수, #좌석번호, 좌석 배정 여부 
상영일정 #상영일정번호, 상영일자, 어떤 영화, 어디 상영관 
간식 #간식번호, 종류, 이름, 가격 
기념품 #기념품번호, 이름, 가격 
10
개체 명 속성 
# : primary key 
회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 
결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자 
예매한 티켓번호와 수량, 주문한 간식/기념품번호와 수량 
티켓 #티켓번호, 상영일정번호, 좌석번호, 가격 
영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 
상영관 #상영관번호, 총 좌석 수, #좌석번호, 좌석 배정 여부 
상영일정 #상영일정번호, 상영일자, 영화번호, 상영관번호 
간식 #간식번호, 종류, 이름, 가격 
기념품 #기념품번호, 이름, 가격 
11
개체 명 속성 
# : primary key 
회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 
결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자 
예매한 티켓번호와 수량, 주문한 간식/기념품번호와 수량 
티켓 #티켓번호, 상영일정번호, 좌석번호, 가격 
영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 
상영관 #상영관번호, 총 좌석 수, #좌석번호, 좌석 배정 여부 
상영일정 #상영일정번호, 상영일자, 영화번호, 상영관번호 
간식 #간식번호, 종류, 이름, 가격 
기념품 #기념품번호, 이름, 가격 
12
개체 명 속성 
# : primary key 
회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 
결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자, 
예매번호, 주문번호 
티켓예매 #예매번호, 티켓번호, 수량 
간식/기념품 주문 #주문번호, 주문한 간식/기념품 번호, 수량 
티켓 #티켓번호, 상영일정번호, 상영관번호, 좌석번호, 가격 
영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 
상영관 #상영관번호, 총 좌석 수 
좌석 #상영관번호, #좌석번호, 좌석 배정 유무 
상영일정 #상영일정번호, 상영일자, 영화번호, 상영관번호 
간식 #간식번호, 종류, 이름, 가격 
기념품 #기념품번호, 이름, 가격 13
14
2-3. DB설계 
15 
/* 고객 테이블 생성 */ 
CREATE TABLE customer 
( 
customer_UID NUMBER(6) NOT NULL, 
customer_id VARCHAR2(30), 
customer_pw VARCHAR2(30), 
customer_name VARCHAR2(20), 
customer_tel NUMBER(12), 
CONSTRAINT customer_customer_UID_pk PRIMARY KEY(customer_UID) 
);
2-3. DB설계 
16 
/* 간식 테이블 생성*/ 
CREATE TABLE snack 
( 
snack_UID NUMBER(6) NOT NULL, 
type varchar2(10), 
name VARCHAR2(20), 
price number(6), 
CONSTRAINT snack_snack_UID_pk PRIMARY KEY(snack_UID) 
); 
/*기념품 테이블 생성 */ 
CREATE TABLE memento 
( 
memento_UID NUMBER(4) NOT NULL, 
name VARCHAR2(21), 
price number(6), 
CONSTRAINT memento_memento_UID_pk PRIMARY KEY(memento_UID) 
);
2-3. DB설계 
17 
/* 기념품 주문 테이블 생성 */ 
create table memento_order 
( 
m_order_uid number(6) not null, 
memento_UID number(6), 
order_quantity number(4), 
constraint memento_m_order_UID_pk primary key(m_order_uid), 
constraint memento_memento_uid_fk foreign key(memento_uid) references memento(memento_uid) 
); 
/* 간식 주문 테이블 생성 */ 
create table snack_order 
( 
s_order_uid number(6) not null, 
p_snack_uid number(6), 
p_order_quantity number(4), 
j_snack_uid number(6), 
j_order_quantity number(4), 
constraint snack_s_order_uid_pk primary key(s_order_uid), 
constraint snack_p_snack_uid_fk foreign key(p_snack_uid) references snack(snack_uid), 
constraint snack_j_snack_uid_fk foreign key( j_snack_uid) references snack(snack_uid) 
);
2-3. DB설계 
18 
/* 상영관 테이블 생성*/ 
CREATE TABLE theater 
( 
theater_UID NUMBER(6) NOT NULL, 
total_seat_number NUMBER(10), 
CONSTRAINT theater_theater_UID_pk PRIMARY KEY(theater_UID) 
); 
/*좌석 테이블 생성*/ 
CREATE TABLE seat 
( 
theater_UID number(4) NOT NULL, 
seat_UID varchar2(10) NOT NULL, 
issue NUMBER(6) not null default 0, 
CONSTRAINT seat_pk PRIMARY KEY(seat_UID, theater_UID), 
constraint seat_theater_UID_fk foreign key(theater_UID) references theater(theater_UID) 
); 
/*영화 테이블 생성*/ 
CREATE TABLE movie 
( 
movie_UID NUMBER(6) NOT NULL, 
title VARCHAR2(20), 
CONSTRAINT movie_movie_UID_pk PRIMARY KEY(movie_UID) 
);
2-3. DB설계 
19 
/* 상영일정 테이블 생성 */ 
CREATE TABLE schedule 
( 
schedule_UID NUMBER(6) NOT NULL, 
schedule_date DATE, 
movie_UID NUMBER(4), 
theater_UID NUMBER(4), 
CONSTRAINT schedule_schedule_UID_pk PRIMARY KEY(schedule_UID), 
CONSTRAINT schedule_movie_UID_fk FOREIGN KEY(movie_UID) REFERENCES movie(movie_UID), 
CONSTRAINT schedule_theater_UID_fk FOREIGN KEY(theater_UID) REFERENCES theater(theater_UID) 
); 
/* 티켓 테이블 생성 */ 
CREATE TABLE ticket 
( 
ticket_UID NUMBER(6) NOT NULL, 
schedule_UID NUMBER(2), 
theater_UID NUMBER(4), 
seat_UID varchar2(10), 
price number(6), 
CONSTRAINT ticket_ticket_UID_pk PRIMARY KEY(ticket_UID), 
CONSTRAINT ticket_schedule_UID_fk FOREIGN KEY(schedule_UID) REFERENCES schedule(schedule_UID), 
constraint ticket_seat_fk foreign key(theater_UID, seat_UID) references seat(theater_UID, seat_UID) 
);
2-3. DB설계 
20 
/* 티켓 예매 테이블 생성 */ 
create table reservation 
( 
reservation_UID number(6) not null, 
ticket1_uid number(6), 
ticket2_uid number(6), 
ticket3_uid number(6), 
ticket4_uid number(7), 
constraint reservation_reservation_UID_pk primary key(reservation_UID), 
constraint reservation_ticket1_uid_fk foreign key(ticket1_uid) references ticket(ticket_uid), 
constraint reservation_ticket2_uid_fk foreign key(ticket2_uid) references ticket(ticket_uid), 
constraint reservation_ticket3_uid_fk foreign key(ticket3_uid) references ticket(ticket_uid), 
constraint reservation_ticket4_uid_fk foreign key(ticket4_uid) references ticket(ticket_uid) 
); 
/* 결제 테이블 생성 */ 
create table payment 
( 
payment_UID number(6) not null, 
total_price number(8), 
payment_option varchar2(20), 
payment_date date, 
customer_UID number(6), 
m_order_UID number(6), 
s_order_UID number(6), 
reservation_UID number(6), 
constraint payment_payment_UID_pk primary key(payment_UID), 
constraint payment_customer_uid_fk FOREIGN KEY(customer_UID)REFERENCES customer(customer_UID), 
CONSTRAINT payment_m_order_UID_fk FOREIGN KEY(m_order_UID)REFERENCES memento_order(m_order_UID), 
CONSTRAINT payment_s_order_UID_fk FOREIGN KEY(s_order_UID)REFERENCES snack_order(s_order_UID), 
CONSTRAINT payment_reservation_UID_fk FOREIGN KEY(reservation_UID)REFERENCES reservation(reservation_UID) 
);
3. 프로그램 – DB연결 
/* 간식 (정보) 삽입 */ 
insert into snack values (1, '팝콘', '치즈맛팝콘', 5000); 
insert into snack values (2, '팝콘', '양파맛팝콘', 5000); 
insert into snack values (3, '팝콘', '코소한맛팝콘', 5000); 
insert into snack values (4, '팝콘', '카라멜맛팝콘', 5000); 
insert into snack values (5, '음료', '콜라', 3000); 
insert into snack values (6, '음료', '사이다', 3000); 
insert into snack values (7, '음료', '에이드', 3000); 
21 
/* 영화 (정보) 삽입 */ 
insert into movie values(1, 'interstellar'); 
insert into movie values(2, 'killyourdarlings'); 
insert into movie values(3, 'frank'); 
/* 상영관 (정보) 삽입 */ 
insert into theater values(1, 69); 
insert into theater values(2, 69); 
insert into theater values(3, 69); 
/* 좌석 (정보) 삽입 */ 
// 엑셀을 통해 삽입 
insert into seat values(1, 'A-1', 0); 
insert into seat values(1, 'A-2', 0); 
...... 
insert into seat values(1, 'A-23', 0); 
...... 
insert into seat values(3, 'C-23', 0); 
/* 기념품 (정보) 삽입 */ 
insert into memento values (1, '모자', 10000); 
insert into memento values (1, '담요', 10000); 
insert into memento values (1, '슬리퍼', 10000); 
/* 상영일정 (정보) 삽입 */ 
insert into schedule values(1, to_date(20141231, 'yyyy-mm-dd'), 1, 1); 
insert into schedule values(2, to_date(20140101, 'yyyy-mm-dd'), 2, 2); 
insert into schedule values(3, to_date(20140102, 'yyyy-mm-dd'), 3, 3);
3. 프로그램 – DB연결 
/* 간식 (정보) 삽입 */ 
insert into snack values (1, '팝콘', '치즈맛팝콘', 5000); 
insert into snack values (2, '팝콘', '양파맛팝콘', 5000); 
insert into snack values (3, '팝콘', '코소한맛팝콘', 5000); 
insert into snack values (4, '팝콘', '카라멜맛팝콘', 5000); 
insert into snack values (5, '음료', '콜라', 3000); 
insert into snack values (6, '음료', '사이다', 3000); 
insert into snack values (7, '음료', '에이드', 3000); 
22 
/* 영화 (정보) 삽입 */ 
영화번호 영화제목 
insert into movie values(1, 'interstellar'); 
insert into movie values(2, 'killyourdarlings'); 
insert into movie values(3, 'frank'); 
1 interstellar 
2 Killyourdarlings 
3 frank 
/* 상영관 (정보) 삽입 */ 
insert into theater values(1, 69); 
상영관번호 총 좌석 수 
insert into theater values(2, 69); 
insert into theater values(3, 69); 
1 69 
2 69 
3 69 
/* 좌석 (정보) 삽입 */ 
// 엑셀을 통해 삽입 
insert into seat values(1, 'A-1', 0); 
insert into seat values(1, 'A-2', 0); 
...... 
insert into seat values(1, 'A-23', 0); 
...... 
insert into seat values(3, 'C-23', 0); 
/* 기념품 (정보) 삽입 */ 
insert into memento values (1, '모자', 10000); 
insert into memento values (1, '담요', 10000); 
insert into memento values (1, '슬리퍼', 10000); 
상영관번호 좌석번호 예약여부 
1 A-1 0 
2 A-2 0 
3 A-3 0 
…. ….. …… 
/* 상영일정 (정보) 삽입 */ 
insert 상영일정번호 into schedule 상영일자 values(영화번호 1, to_date(상영관번호 
20141231, 'yyyy-mm-dd'), 1, 1); 
insert into schedule values(2, to_date(20140101, 'yyyy-mm-dd'), 2, 2); 
insert into schedule values(3, to_date(20140102, 'yyyy-mm-dd'), 3, 3); 
1 20141231 1 1 
2 20140101 2 2 
간식번호 종류 이름 가격 
1 팝콘 치즈맛팝콘 5000 
2 팝콘 양파맛팝콘 5000 
3 팝콘 고소한맛팝콘 5000 
4 팝콘 카라멜맛팝콘 5000 
5 음료 콜라 3000 
6 음료 사이다 3000 
7 음료 에이드 3000 
기념품번호 이름 가격 
1 모자 10000 
2 담요 10000 
3 슬리퍼 10000
2-3. DB설계 
23 
/* customer_UID를 위한 sequence 생성 */ 
create sequence customer_UID; 
/* ticket_UID를 위한 sequence 생성 */ 
create sequence ticket_UID; 
/* 티켓 생성! */ 
// 자바 코드를 통해 생성 
try { 
String query = "select schedule_uid, seat.theater_uid, seat_uid from schedule, seat where 
schedule.theater_uid = seat.theater_uid"; 
Statement stmt = con.createStatement(); 
ResultSet rs = stmt.executeQuery(query); 
while(rs.next()){ 
String inQuery = "insert into ticket values (ticket_uid.nextval, " 
+ rs.getInt(1) + ", " + rs.getInt(2) + ", '" + rs.getString(3) + "', 8000)"; 
Statement inStmt = con.createStatement(); 
ResultSet inRs = inStmt.executeQuery(inQuery); 
} 
} catch(SQLException e) { 
e.printStackTrace(); 
} 
/* 예매를 위한 sequence 생성 */ 
create sequence reservation_uid; 
/* 결제를 위한 sequence 생성 */ 
create sequence payment_UID;
2-3. DB설계 
24 
/* customer_UID를 위한 sequence 생성 */ 
create sequence customer_UID; 
/* ticket_UID를 위한 sequence 생성 */ 
create sequence ticket_UID; 
/* 티켓 생성! */ 
// 자바 코드를 통해 생성 
try { 
String query = "select schedule_uid, seat.theater_uid, seat_uid from schedule, seat where 
schedule.theater_uid = seat.theater_uid"; 
Statement stmt = con.createStatement(); 
ResultSet rs = stmt.executeQuery(query); 
while(rs.next()){ 
String inQuery = "insert into ticket values (ticket_uid.nextval, " 
+ rs.getInt(1) + ", " + rs.getInt(2) + ", '" + rs.getString(3) + "', 8000)"; 
Statement inStmt = con.createStatement(); 
ResultSet inRs = inStmt.executeQuery(inQuery); 
} 
} catch(SQLException e) { 
e.printStackTrace(); 
} 
/* 예매를 위한 sequence 생성 */ 
create sequence reservation_uid; 
/* 결제를 위한 sequence 생성 */ 
create sequence payment_UID; 
티켓번호 상영일정번호 상영관번호 좌석번호 가격 
1 1 1 A-1 8000
3. 프로그램 – DB연결 
25 
class MovieInfo { 
String title; 
String image; 
} 
DB와 정보를 주고받을 객체 생성! 
class SeatInfo { 
String seat_UID; 
int issue; 
} 
class MyPayment { 
int total_price; 
String option; 
java.sql.Date date; 
int my_UID; 
int reservation_UID; 
int m_order_uid; 
int s_order_uid; 
} 
class Customer { 
String id; 
String pw; 
String name; 
int tel; 
} 
class Selected { 
String movie_title; 
int theater; 
int num_of_person; 
String seat; 
int p_snack; 
int p_snack_quantity; 
int j_snack; 
int j_snack_quantity; 
int memento; 
int memento_quantity; 
String payment_option; 
}
public boolean 회원가입창아이디중복검사(String 아이디) { 
try { 
String query = "select * from customer where customer_id='"+아이디+"'"; 
Statement statement = con.createStatement(); 
ResultSet resultSet = statement.executeQuery(query); 
if(resultSet.next()) { 
try { 
con.close(); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
return true; 
} 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
try { 
con.close(); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
return false; 
} 
3-2. 프로그램 – DB연결 
26
3-2. 프로그램 – DB연결 
27 
public void signUp(String id, String pw, String name, String telStr) { 
StringTokenizer st = new StringTokenizer(telStr, "-"); 
String str = ""; 
while(st.hasMoreTokens()) { 
str += st.nextToken(); 
} 
int tel = Integer.parseInt(str); 
try { 
String query = "insert into customer values 
(customer_uid.nextval, '"+id+"', '"+pw+"', '"+name+"', "+tel+")"; 
Statement statement = con.createStatement(); 
ResultSet resultSet = statement.executeQuery(query); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
try { 
con.close(); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
}
3-2. 프로그램 – DB연결 
28 
public boolean 로그인창아이디검사(String 아이디) { 
try { 
String query = "select * from customer where customer_id='"+아이디+"'"; 
Statement statement = con.createStatement(); 
ResultSet resultSet = statement.executeQuery(query); 
if(resultSet.next()) { 
try { 
con.close(); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
return true; 
} 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
try { 
con.close(); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
return false; 
}
3-2. 프로그램 – DB연결 
29 
public boolean 로그인창비밀번호검사(String 비밀번호) { 
try { 
String query = "select * from customer where customer_pw='"+비밀번호+"'"; 
Statement statement = con.createStatement(); 
ResultSet resultSet = statement.executeQuery(query); 
if(resultSet.next()) { 
try { 
con.close(); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
return true; 
} 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
try { 
con.close(); 
} catch (SQLException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
} 
return false; 
}
3-2. 프로그램 – DB연결 
30 
/* 로그인 되면 제일 먼저 회원 번호 가져오기! */ 
try { 
String query = "select customer_UID from customer where customer_id = '" + id +"'"; 
Statement statement = con.createStatement(); 
ResultSet rs = statement.executeQuery(query); 
while(rs.next()) { 
myPayment.my_UID = rs.getInt(1); 
} 
System.out.println("my_UID : " + myPayment.my_UID); 
} catch (SQLException e) { 
e.printStackTrace(); 
} 
/* 영화정보 가져오기! */ 
try { 
String query = "select title from movie"; 
Statement statement = con.createStatement(); 
ResultSet rs = statement.executeQuery(query); 
while(rs.next()) { 
MovieInfo mi = new MovieInfo(); 
mi.title = rs.getString(1); 
mi.image = "./images/" + mi.title + ".png"; 
movieInfo.add(mi); 
} 
} catch (SQLException e1) { 
// TODO Auto-generated catch block 
e1.printStackTrace(); 
}
3-2. 프로그램 – DB연결 
31 
/* 상영관정보 가져오기! */ 
try { 
String query = "select theater_UID from schedule where movie_UID = 
(select movie_UID from movie where title = '" + selected.movie_title +"')"; 
Statement stmt = con.createStatement(); 
ResultSet rs = stmt.executeQuery(query); 
while(rs.next()) { 
selected.theater = rs.getInt(1); 
} 
System.out.println( 
selected.movie_title + ", " 
+ selected.theater); 
} catch (SQLException e1) { 
e1.printStackTrace(); 
}
3-2. 프로그램 – DB연결 
32 
/* 좌석 정보(예약 여부) 가져오기! */ 
try { 
String query = "select seat_UID, issue from seat where theater_UID = " + selected.theater; 
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); 
ResultSet rs = stmt.executeQuery(query); 
rs.last(); 
seatInfo = new SeatInfo[rs.getRow()]; 
rs.beforeFirst(); 
while(rs.next()){ 
char[] tmp_uid = rs.getString(1).toCharArray(); 
String tmpStr = ""; 
for (int i = 2; i < tmp_uid.length; i++) { 
tmpStr += tmp_uid[i]; 
} 
int seatInfoIndex = (int)((tmp_uid[0])-'A')*24 + Integer.parseInt(tmpStr); 
seatInfo[seatInfoIndex] = new SeatInfo(); 
seatInfo[seatInfoIndex].seat_UID = rs.getString(1); 
seatInfo[seatInfoIndex].issue = rs.getInt(2); 
} 
// 예약 좌석에 해당하는 JCheckBox 끄기! 
for (int i = 0; i < seatInfo.length; i++) { 
if (seatInfo[i].issue == 1) { 
seat[(int)(i/24)][i%24].setEnabled(false); 
} 
} 
} catch (SQLException e1) { 
// TODO Auto-generated catch block 
e1.printStackTrace(); 
}
3-2. 프로그램 – DB연결 
33 
// 간식 (팝콘류, 음료류) 가져오기! 
try { 
String query = "select name, price from 
snack where type = '팝콘'"; 
Statement stmt = 
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIV 
E, ResultSet.CONCUR_UPDATABLE); 
ResultSet rs = stmt.executeQuery(query); 
rs.last(); 
listP = new String[rs.getRow() + 1]; 
popcornPrice = new int[rs.getRow() + 1]; 
rs.beforeFirst(); 
listP[0] = "팝콘"; 
popcornPrice[0] = 0; 
int listIndex = 0; 
while(rs.next()) { 
listP[++listIndex] = rs.getString(1); 
popcornPrice[listIndex] = rs.getInt(2); 
} 
query = "select name, price from snack 
where type = '음료'"; 
rs = stmt.executeQuery(query); 
rs.last(); 
listJ = new String[rs.getRow() + 1]; 
juicePrice = new int[rs.getRow() + 1]; 
rs.beforeFirst(); 
listJ[0] = "음료"; 
juicePrice[0] = 0; 
listIndex = 0; 
while(rs.next()) { 
listJ[++listIndex] = rs.getString(1); 
juicePrice[listIndex] = rs.getInt(2); 
} 
} catch(SQLException e) { 
e.printStackTrace(); 
}
3-2. 프로그램 – DB연결 
34 
// 기념품 가져오기! 
try { 
String query = "select name from memento"; 
Statement stmt = 
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, 
ResultSet.CONCUR_UPDATABLE); 
ResultSet rs = stmt.executeQuery(query); 
rs.last(); 
listS = new String[rs.getRow() + 1]; 
rs.beforeFirst(); 
listS[0] = "기념품"; 
int listIndex = 1; 
while(rs.next()) { 
listS[listIndex++] = rs.getString(1); 
} 
} catch(SQLException e) { 
e.printStackTrace(); 
}
3-2. 프로그램 – DB연결 
35 
if ((selected.p_snack >0 || selected.j_snack >0)) 
{ 
String p_order = (selected.p_snack>0?""+selected.p_snack:"null") + ", null"; 
String j_order = (selected.j_snack>0?""+selected.j_snack:"null") + ", null"; 
// 스낵 주문정보를 DB에 추가 
query = "insert into snack_order values “ 
+ "(snack_order_uid.nextVal, " + p_order + ", " + j_order + ")"; 
rs = stmt.executeQuery(query); 
// 주문번호 바로 가져오기! 
query = "select s_order_uid from snack_order"; 
rs = stmt.executeQuery(query); 
rs.last(); 
myPayment.s_order_uid = rs.getInt(1); 
} else { 
myPayment.s_order_uid = -1; 
}
3-2. 프로그램 – DB연결 
36 
if ((selected.p_snack >0 || selected.j_snack >0)) 
{ 
String p_order = (selected.p_snack>0?""+selected.p_snack:"null") + ", null"; 
String j_order = (selected.j_snack>0?""+selected.j_snack:"null") + ", null"; 
// 스낵 주문정보를 DB에 추가 
query = "insert into snack_order values “ 
+ "(snack_order_uid.nextVal, " + p_order + ", " + j_order + ")"; 
rs = stmt.executeQuery(query); 
// 주문번호 바로 가져오기! 
query = "select s_order_uid from snack_order"; 
rs = stmt.executeQuery(query); 
rs.last(); 
myPayment.s_order_uid = rs.getInt(1); 
} else { 
myPayment.s_order_uid = -1; 
} 
주문번호 팝콘간식번호 팝콘주문수량 음료간식번호 음료주문수량 
141201 001 2 002 3
4. 조원 역할 
37 
if (selected.memento >0) 
{ 
// 기념품 주문정보를 DB에 추가 
query = "insert into memento_order values " 
+ "(memento_order_uid.nextVal, " + selected.memento + ", " 
+ selected.memento_quantity +")"; 
rs = stmt.executeQuery(query); 
// 주문정보 바로 가져오기! 
query = "select m_order_uid from memento_order"; 
rs = stmt.executeQuery(query); 
rs.last(); 
myPayment.m_order_uid = rs.getInt(1); 
} else { 
myPayment.m_order_uid = -1; 
}
4. 조원 역할 
38 
if (selected.memento >0) 
{ 
// 기념품 주문정보를 DB에 추가 
query = "insert into memento_order values " 
+ "(memento_order_uid.nextVal, " + selected.memento + ", " 
+ selected.memento_quantity +")"; 
rs = stmt.executeQuery(query); 
// 주문정보 바로 가져오기! 
query = "select m_order_uid from memento_order"; 
rs = stmt.executeQuery(query); 
rs.last(); 
myPayment.m_order_uid = rs.getInt(1); 
} else { 
myPayment.m_order_uid = -1; 
} 
주문번호 기념품번호 기념품주문수량 
241217 002 3
4. 조원 역할 
39 
// 예약할 좌석을 예약상태로 바꾼 뒤, 티켓번호를 알아낸다. 
int[] ticket_UID = new int[4]; 
for (int i = 0; i < selected_seat.length; i++) { 
System.out.println(selected.theater + ", " + selected_seat[i]); 
query = "update seat set issue = 1 where theater_UID = " + 
selected.theater + " and seat_UID = '" + selected_seat[i]+ "'"; 
rs = stmt.executeQuery(query); 
/* 커밋한번 해준다. */ 
query = "commit"; 
rs = stmt.executeQuery(query); 
query = "select ticket_UID from ticket where theater_UID = " + 
selected.theater + " and seat_UID = '" + selected_seat[i] + "'"; 
rs = stmt.executeQuery(query); 
while(rs.next()) ticket_UID[i] = rs.getInt(1); 
}
4. 조원 역할 
40 
// 예매정보를 DB에 추가하고 예매번호를 확인한다. 
query = "insert into reservation values " 
+ "(reservation_uid.nextval, " + ticket_UID[0] +", “ 
+ (ticket_UID[1]>0?ticket_UID[1]:null) +", " 
+ (ticket_UID[2]>0?ticket_UID[2]:null) +", “ 
+ (ticket_UID[3]>0?ticket_UID[3]:null) +")"; 
rs = stmt.executeQuery(query); 
/* 커밋한번 해준다. */ 
query = "commit"; 
rs = stmt.executeQuery(query); 
query = "select reservation_uid from reservation"; 
rs = stmt.executeQuery(query); 
rs.last(); 
myPayment.reservation_UID = rs.getInt(1);
4. 조원 역할 
41 
// 예매정보를 DB에 추가하고 예매번호를 확인한다. 
query = "insert into reservation values " 
+ "(reservation_uid.nextval, " + ticket_UID[0] +", “ 
+ (ticket_UID[1]>0?ticket_UID[1]:null) +", " 
+ (ticket_UID[2]>0?ticket_UID[2]:null) +", “ 
+ (ticket_UID[3]>0?ticket_UID[3]:null) +")"; 
예매 번호 티켓1 번호 티켓2 번호 티켓3 번호 티켓4 번호 
371217 1001 1010 1011 1100 
rs = stmt.executeQuery(query); 
/* 커밋한번 해준다. */ 
query = "commit"; 
rs = stmt.executeQuery(query); 
query = "select reservation_uid from reservation"; 
rs = stmt.executeQuery(query); 
rs.last(); 
myPayment.reservation_UID = rs.getInt(1);
4. 조원 역할 
42 
// 최종 결제 정보를 DB에 추가 
try { 
String query = "insert into payment values (payment_uid.nextVal, " 
+ myPayment.total_price + ", '" + myPayment.option 
+ "', to_date('" + today + "', 'MM-DD-YYYY'), " 
+ myPayment.my_UID + ", " 
+ (myPayment.m_order_uid>0?myPayment.m_order_uid:null) + ", " 
+ (myPayment.s_order_uid>0?myPayment.s_order_uid:null) + ", " 
+ myPayment.reservation_UID + ")"; 
Statement stmt = con.createStatement(); 
ResultSet rs = stmt.executeQuery(query); 
} catch(SQLException exception) { 
exception.printStackTrace(); 
}
4. 조원 역할 
43 
// 최종 결제 정보를 DB에 추가 
try { 
String query = "insert into payment values (payment_uid.nextVal, " 
+ myPayment.total_price + ", '" + myPayment.option 
+ "', to_date('" + today + "', 'MM-DD-YYYY'), " 
+ myPayment.my_UID + ", " 
+ (myPayment.m_order_uid>0?myPayment.m_order_uid:null) + ", " 
+ (myPayment.s_order_uid>0?myPayment.s_order_uid:null) + ", " 
+ myPayment.reservation_UID + ")"; 
Statement stmt = con.createStatement(); 
ResultSet rs = stmt.executeQuery(query); 
} catch(SQLException exception) { 
exception.printStackTrace(); 
} 
결결제제번번호호 총총 가가격격 결결제제 방방법법 결결제제 일일자자 회회원원 번번호호 기기념념품품주주문문번번호호 간간식식주주문문번번호호 예예매매번번호호 
941214 27000 카드 20141207 0 241217 141201 371217
4. 결과물 
44 
프로그램 실행
5. 연동하면서 특별히 어려웠던 점 
45 
1. 자바 연동 전, 테이블에 대량의 데이터를 삽입할 때 
→ Excel을 이용하여 데이터 삽입! (정보 링크 : here) 
2. Oracle DB와 JAVA간의 한글 깨짐 현상과 날짜형식이 맞지 않았다. 
→ 캐릭터 셋을 확인하고 변경! 
(NLS_CHARACTERSET이 KO16KSC5601인지 확인!) 
→ 날짜 형식 변경 
(alter session set nls_date_format='yyyymmdd hh24:mi:ss';)
6. 각 조원의 역할은? 
46 
1. 최명근 : 프로그램 작성, DB 테이블 작성 
2. 서진영 : DB 설계 공부 
3. 이성광 : DB 설계 공부 & 테이블 작성 
4. 방소영 : 프로그램 작성, PPT 작성 
5. 전유진 : DB설계, 프로그램-DB연동, PPT 작성
47

More Related Content

What's hot

Failles de sécurité Web et Symfony
Failles de sécurité Web et SymfonyFailles de sécurité Web et Symfony
Failles de sécurité Web et SymfonyChamalaine Soufi
 
송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010devCAT Studio, NEXON
 
4조 졸업작품 ppt
4조 졸업작품 ppt4조 졸업작품 ppt
4조 졸업작품 pptssuser767696
 
Mieux Filtrer ses listes WordPress avec Ajax et WP_Query
Mieux Filtrer ses listes WordPress avec Ajax et WP_QueryMieux Filtrer ses listes WordPress avec Ajax et WP_Query
Mieux Filtrer ses listes WordPress avec Ajax et WP_QuerySymetris
 
게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집 게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집 CookApps
 
악플분류 모델링 프로젝트
악플분류 모델링 프로젝트악플분류 모델링 프로젝트
악플분류 모델링 프로젝트DataScienceLab
 
Windows IOCP vs Linux EPOLL Performance Comparison
Windows IOCP vs Linux EPOLL Performance ComparisonWindows IOCP vs Linux EPOLL Performance Comparison
Windows IOCP vs Linux EPOLL Performance ComparisonSeungmo Koo
 
게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)
게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)
게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)Hyeyon Kwon
 
[분석] DeepTitle : 한국어 기사 자동 요약
[분석] DeepTitle : 한국어 기사 자동 요약[분석] DeepTitle : 한국어 기사 자동 요약
[분석] DeepTitle : 한국어 기사 자동 요약BOAZ Bigdata
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesOdoo
 
2nd.lecture.who.i.am.as.a.designer
2nd.lecture.who.i.am.as.a.designer2nd.lecture.who.i.am.as.a.designer
2nd.lecture.who.i.am.as.a.designerJeongeun Kwon
 
멘탈모델 1-3장 자료
멘탈모델 1-3장 자료멘탈모델 1-3장 자료
멘탈모델 1-3장 자료beom kyun choi
 
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축BOAZ Bigdata
 
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기강 민우
 
심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018
심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018
심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018devCAT Studio, NEXON
 
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webappsMikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webappshacktivity
 
기가박스 영화관 운영 시스템 구축마지막
기가박스 영화관 운영 시스템 구축마지막기가박스 영화관 운영 시스템 구축마지막
기가박스 영화관 운영 시스템 구축마지막ssuser5280ce
 
영속성 컨텍스트로 보는 JPA
영속성 컨텍스트로 보는 JPA영속성 컨텍스트로 보는 JPA
영속성 컨텍스트로 보는 JPA경원 이
 
스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나
스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나
스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나Lee Sangkyoon (Kay)
 
프로그래머에게 사랑받는 게임 기획서 작성법
프로그래머에게 사랑받는 게임 기획서 작성법프로그래머에게 사랑받는 게임 기획서 작성법
프로그래머에게 사랑받는 게임 기획서 작성법Lee Sangkyoon (Kay)
 

What's hot (20)

Failles de sécurité Web et Symfony
Failles de sécurité Web et SymfonyFailles de sécurité Web et Symfony
Failles de sécurité Web et Symfony
 
송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010송창규, unity build로 빌드타임 반토막내기, NDC2010
송창규, unity build로 빌드타임 반토막내기, NDC2010
 
4조 졸업작품 ppt
4조 졸업작품 ppt4조 졸업작품 ppt
4조 졸업작품 ppt
 
Mieux Filtrer ses listes WordPress avec Ajax et WP_Query
Mieux Filtrer ses listes WordPress avec Ajax et WP_QueryMieux Filtrer ses listes WordPress avec Ajax et WP_Query
Mieux Filtrer ses listes WordPress avec Ajax et WP_Query
 
게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집 게임회사 실무용어 완전정복! 쿡앱스 용어정리집
게임회사 실무용어 완전정복! 쿡앱스 용어정리집
 
악플분류 모델링 프로젝트
악플분류 모델링 프로젝트악플분류 모델링 프로젝트
악플분류 모델링 프로젝트
 
Windows IOCP vs Linux EPOLL Performance Comparison
Windows IOCP vs Linux EPOLL Performance ComparisonWindows IOCP vs Linux EPOLL Performance Comparison
Windows IOCP vs Linux EPOLL Performance Comparison
 
게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)
게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)
게임 유저 행동 분석으로 이탈 방지하는 방법 (텐투플레이 웨비나)
 
[분석] DeepTitle : 한국어 기사 자동 요약
[분석] DeepTitle : 한국어 기사 자동 요약[분석] DeepTitle : 한국어 기사 자동 요약
[분석] DeepTitle : 한국어 기사 자동 요약
 
Impact of the New ORM on Your Modules
Impact of the New ORM on Your ModulesImpact of the New ORM on Your Modules
Impact of the New ORM on Your Modules
 
2nd.lecture.who.i.am.as.a.designer
2nd.lecture.who.i.am.as.a.designer2nd.lecture.who.i.am.as.a.designer
2nd.lecture.who.i.am.as.a.designer
 
멘탈모델 1-3장 자료
멘탈모델 1-3장 자료멘탈모델 1-3장 자료
멘탈모델 1-3장 자료
 
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축
제 17회 보아즈(BOAZ) 빅데이터 컨퍼런스 - [Catch, Traffic!] : 지하철 혼잡도 및 키워드 분석 데이터 파이프라인 구축
 
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
[IGC 2017] 펄어비스 민경인 - Mmorpg를 위한 voxel 기반 네비게이션 라이브러리 개발기
 
심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018
심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018
심예람, <프로젝트DH> AI 내비게이션 시스템, NDC2018
 
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webappsMikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
Mikhail Egorov - Hunting for bugs in Adobe Experience Manager webapps
 
기가박스 영화관 운영 시스템 구축마지막
기가박스 영화관 운영 시스템 구축마지막기가박스 영화관 운영 시스템 구축마지막
기가박스 영화관 운영 시스템 구축마지막
 
영속성 컨텍스트로 보는 JPA
영속성 컨텍스트로 보는 JPA영속성 컨텍스트로 보는 JPA
영속성 컨텍스트로 보는 JPA
 
스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나
스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나
스토리텔링과 비주얼 내러티브: 놀 치프틴은 어떻게 형님이 되었나
 
프로그래머에게 사랑받는 게임 기획서 작성법
프로그래머에게 사랑받는 게임 기획서 작성법프로그래머에게 사랑받는 게임 기획서 작성법
프로그래머에게 사랑받는 게임 기획서 작성법
 

영화 예매 프로그램 (DB 설계, 프로그램 연동)

  • 1. 영화 예매’만' 프로그램 DB 설계 0901289 최명근 1101131 서진영 1101196 이성광 1301131 방소영 1301243 전유진 1
  • 2. 목 차 1. 프로그램 설명 2. DB 설계 3. 프로그램 – DB 연결 4. 결과물 5. 연동하면서 어려웠던 점 6. 각 조원의 역할은? 2
  • 3. 1. 프로그램 설명 로그인 - 회원 가입 3
  • 4. 3-1. 프로그램 4 메인 - 영화선택창
  • 5. 3-1. 프로그램 5 매수 - 좌석선택창
  • 6. 3-1. 프로그램 간식 주문 – 기념품 주문 창 6
  • 8. 2. DB 설계 회원제로 관리되는 영화 예매 프로그램이다. 프로그램을 시작하여 예매 버튼을 누르면 영화를 선택할 수 있다. 상영관은 각 영 화마다 정해져 있다. 상영일정 역시 정해져 있어서 고르지 않는다. 영화 선택 후, 영 화 관람 인원 수 (예매할 티켓의 매수)를 정해야 한다. 정한 인원 수 만큼 예매가 가 능한 좌석을 선택할 수 있다. 영화 종류/좌석 선택 이후, 간식(팝콘과 음료)과 기념품을 구매할 수 있다. 구매하 지 않아도 된다. 간식(팝콘과 음료)과 종류와 개수를 선택할 수 있다. 마지막으로 고객은 결제 방법(3가지)을 선택한다. 결제 완료 이후, 고객은 결제된 내용을 다시 확인이 가능하다. /* 참고 사항 */ 회원가입 할 때 아이디, 비밀번호, 이름, 전화번호정보가 필요하다. 좌석은 한번에 최대 4자리 씩만 선택할 수 있다. 8
  • 9. 회원제로 관리되는 영화 예매 프로그램이다. 프로그램을 시작하여 예매 버튼을 누르면 영화를 선택할 수 있다. 상영관은 각 영 화마다 정해져 있다. 상영일정 역시 정해져 있어서 고르지 않는다. 영화 선택 후, 영 화 관람 인원 수 (예매할 티켓의 매수)를 정해야 한다. 정한 인원 수 만큼 예매가 가 능한 좌석을 선택할 수 있다. 영화 종류/좌석 선택 이후, 간식(팝콘과 음료)과 기념품을 구매할 수 있다. 구매하 지 않아도 된다. 간식(팝콘과 음료)과 기념품은 종류와 개수를 선택할 수 있다. 마지막으로 고객은 결제 방법(3가지)을 선택한다. 결제 완료 이후, 고객은 결제된 내용을 다시 확인이 가능하다. /* 참고 사항 */ 회원가입 할 때 아이디, 비밀번호, 이름, 전화번호정보가 필요하다. 좌석은 한번에 최대 4자리 씩만 선택할 수 있다. 9
  • 10. 개체 명 속성 # : primary key 회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자 예매한 티켓번호와 수량, 주문한 간식/기념품번호와 수량 티켓 #티켓번호, 언제, 어떤 영화, 어디서, 좌석번호, 가격 영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 상영관 #상영관번호, 총 좌석 수, #좌석번호, 좌석 배정 여부 상영일정 #상영일정번호, 상영일자, 어떤 영화, 어디 상영관 간식 #간식번호, 종류, 이름, 가격 기념품 #기념품번호, 이름, 가격 10
  • 11. 개체 명 속성 # : primary key 회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자 예매한 티켓번호와 수량, 주문한 간식/기념품번호와 수량 티켓 #티켓번호, 상영일정번호, 좌석번호, 가격 영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 상영관 #상영관번호, 총 좌석 수, #좌석번호, 좌석 배정 여부 상영일정 #상영일정번호, 상영일자, 영화번호, 상영관번호 간식 #간식번호, 종류, 이름, 가격 기념품 #기념품번호, 이름, 가격 11
  • 12. 개체 명 속성 # : primary key 회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자 예매한 티켓번호와 수량, 주문한 간식/기념품번호와 수량 티켓 #티켓번호, 상영일정번호, 좌석번호, 가격 영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 상영관 #상영관번호, 총 좌석 수, #좌석번호, 좌석 배정 여부 상영일정 #상영일정번호, 상영일자, 영화번호, 상영관번호 간식 #간식번호, 종류, 이름, 가격 기념품 #기념품번호, 이름, 가격 12
  • 13. 개체 명 속성 # : primary key 회원(고객) #회원번호, 아이디, 비밀번호, 이름, 전화번호 결제 #결제번호, 회원번호, 결제방법, 총 가격, 결제일자, 예매번호, 주문번호 티켓예매 #예매번호, 티켓번호, 수량 간식/기념품 주문 #주문번호, 주문한 간식/기념품 번호, 수량 티켓 #티켓번호, 상영일정번호, 상영관번호, 좌석번호, 가격 영화 #영화번호, 제목, 내용, 감독, 출연배우, 등… 상영관 #상영관번호, 총 좌석 수 좌석 #상영관번호, #좌석번호, 좌석 배정 유무 상영일정 #상영일정번호, 상영일자, 영화번호, 상영관번호 간식 #간식번호, 종류, 이름, 가격 기념품 #기념품번호, 이름, 가격 13
  • 14. 14
  • 15. 2-3. DB설계 15 /* 고객 테이블 생성 */ CREATE TABLE customer ( customer_UID NUMBER(6) NOT NULL, customer_id VARCHAR2(30), customer_pw VARCHAR2(30), customer_name VARCHAR2(20), customer_tel NUMBER(12), CONSTRAINT customer_customer_UID_pk PRIMARY KEY(customer_UID) );
  • 16. 2-3. DB설계 16 /* 간식 테이블 생성*/ CREATE TABLE snack ( snack_UID NUMBER(6) NOT NULL, type varchar2(10), name VARCHAR2(20), price number(6), CONSTRAINT snack_snack_UID_pk PRIMARY KEY(snack_UID) ); /*기념품 테이블 생성 */ CREATE TABLE memento ( memento_UID NUMBER(4) NOT NULL, name VARCHAR2(21), price number(6), CONSTRAINT memento_memento_UID_pk PRIMARY KEY(memento_UID) );
  • 17. 2-3. DB설계 17 /* 기념품 주문 테이블 생성 */ create table memento_order ( m_order_uid number(6) not null, memento_UID number(6), order_quantity number(4), constraint memento_m_order_UID_pk primary key(m_order_uid), constraint memento_memento_uid_fk foreign key(memento_uid) references memento(memento_uid) ); /* 간식 주문 테이블 생성 */ create table snack_order ( s_order_uid number(6) not null, p_snack_uid number(6), p_order_quantity number(4), j_snack_uid number(6), j_order_quantity number(4), constraint snack_s_order_uid_pk primary key(s_order_uid), constraint snack_p_snack_uid_fk foreign key(p_snack_uid) references snack(snack_uid), constraint snack_j_snack_uid_fk foreign key( j_snack_uid) references snack(snack_uid) );
  • 18. 2-3. DB설계 18 /* 상영관 테이블 생성*/ CREATE TABLE theater ( theater_UID NUMBER(6) NOT NULL, total_seat_number NUMBER(10), CONSTRAINT theater_theater_UID_pk PRIMARY KEY(theater_UID) ); /*좌석 테이블 생성*/ CREATE TABLE seat ( theater_UID number(4) NOT NULL, seat_UID varchar2(10) NOT NULL, issue NUMBER(6) not null default 0, CONSTRAINT seat_pk PRIMARY KEY(seat_UID, theater_UID), constraint seat_theater_UID_fk foreign key(theater_UID) references theater(theater_UID) ); /*영화 테이블 생성*/ CREATE TABLE movie ( movie_UID NUMBER(6) NOT NULL, title VARCHAR2(20), CONSTRAINT movie_movie_UID_pk PRIMARY KEY(movie_UID) );
  • 19. 2-3. DB설계 19 /* 상영일정 테이블 생성 */ CREATE TABLE schedule ( schedule_UID NUMBER(6) NOT NULL, schedule_date DATE, movie_UID NUMBER(4), theater_UID NUMBER(4), CONSTRAINT schedule_schedule_UID_pk PRIMARY KEY(schedule_UID), CONSTRAINT schedule_movie_UID_fk FOREIGN KEY(movie_UID) REFERENCES movie(movie_UID), CONSTRAINT schedule_theater_UID_fk FOREIGN KEY(theater_UID) REFERENCES theater(theater_UID) ); /* 티켓 테이블 생성 */ CREATE TABLE ticket ( ticket_UID NUMBER(6) NOT NULL, schedule_UID NUMBER(2), theater_UID NUMBER(4), seat_UID varchar2(10), price number(6), CONSTRAINT ticket_ticket_UID_pk PRIMARY KEY(ticket_UID), CONSTRAINT ticket_schedule_UID_fk FOREIGN KEY(schedule_UID) REFERENCES schedule(schedule_UID), constraint ticket_seat_fk foreign key(theater_UID, seat_UID) references seat(theater_UID, seat_UID) );
  • 20. 2-3. DB설계 20 /* 티켓 예매 테이블 생성 */ create table reservation ( reservation_UID number(6) not null, ticket1_uid number(6), ticket2_uid number(6), ticket3_uid number(6), ticket4_uid number(7), constraint reservation_reservation_UID_pk primary key(reservation_UID), constraint reservation_ticket1_uid_fk foreign key(ticket1_uid) references ticket(ticket_uid), constraint reservation_ticket2_uid_fk foreign key(ticket2_uid) references ticket(ticket_uid), constraint reservation_ticket3_uid_fk foreign key(ticket3_uid) references ticket(ticket_uid), constraint reservation_ticket4_uid_fk foreign key(ticket4_uid) references ticket(ticket_uid) ); /* 결제 테이블 생성 */ create table payment ( payment_UID number(6) not null, total_price number(8), payment_option varchar2(20), payment_date date, customer_UID number(6), m_order_UID number(6), s_order_UID number(6), reservation_UID number(6), constraint payment_payment_UID_pk primary key(payment_UID), constraint payment_customer_uid_fk FOREIGN KEY(customer_UID)REFERENCES customer(customer_UID), CONSTRAINT payment_m_order_UID_fk FOREIGN KEY(m_order_UID)REFERENCES memento_order(m_order_UID), CONSTRAINT payment_s_order_UID_fk FOREIGN KEY(s_order_UID)REFERENCES snack_order(s_order_UID), CONSTRAINT payment_reservation_UID_fk FOREIGN KEY(reservation_UID)REFERENCES reservation(reservation_UID) );
  • 21. 3. 프로그램 – DB연결 /* 간식 (정보) 삽입 */ insert into snack values (1, '팝콘', '치즈맛팝콘', 5000); insert into snack values (2, '팝콘', '양파맛팝콘', 5000); insert into snack values (3, '팝콘', '코소한맛팝콘', 5000); insert into snack values (4, '팝콘', '카라멜맛팝콘', 5000); insert into snack values (5, '음료', '콜라', 3000); insert into snack values (6, '음료', '사이다', 3000); insert into snack values (7, '음료', '에이드', 3000); 21 /* 영화 (정보) 삽입 */ insert into movie values(1, 'interstellar'); insert into movie values(2, 'killyourdarlings'); insert into movie values(3, 'frank'); /* 상영관 (정보) 삽입 */ insert into theater values(1, 69); insert into theater values(2, 69); insert into theater values(3, 69); /* 좌석 (정보) 삽입 */ // 엑셀을 통해 삽입 insert into seat values(1, 'A-1', 0); insert into seat values(1, 'A-2', 0); ...... insert into seat values(1, 'A-23', 0); ...... insert into seat values(3, 'C-23', 0); /* 기념품 (정보) 삽입 */ insert into memento values (1, '모자', 10000); insert into memento values (1, '담요', 10000); insert into memento values (1, '슬리퍼', 10000); /* 상영일정 (정보) 삽입 */ insert into schedule values(1, to_date(20141231, 'yyyy-mm-dd'), 1, 1); insert into schedule values(2, to_date(20140101, 'yyyy-mm-dd'), 2, 2); insert into schedule values(3, to_date(20140102, 'yyyy-mm-dd'), 3, 3);
  • 22. 3. 프로그램 – DB연결 /* 간식 (정보) 삽입 */ insert into snack values (1, '팝콘', '치즈맛팝콘', 5000); insert into snack values (2, '팝콘', '양파맛팝콘', 5000); insert into snack values (3, '팝콘', '코소한맛팝콘', 5000); insert into snack values (4, '팝콘', '카라멜맛팝콘', 5000); insert into snack values (5, '음료', '콜라', 3000); insert into snack values (6, '음료', '사이다', 3000); insert into snack values (7, '음료', '에이드', 3000); 22 /* 영화 (정보) 삽입 */ 영화번호 영화제목 insert into movie values(1, 'interstellar'); insert into movie values(2, 'killyourdarlings'); insert into movie values(3, 'frank'); 1 interstellar 2 Killyourdarlings 3 frank /* 상영관 (정보) 삽입 */ insert into theater values(1, 69); 상영관번호 총 좌석 수 insert into theater values(2, 69); insert into theater values(3, 69); 1 69 2 69 3 69 /* 좌석 (정보) 삽입 */ // 엑셀을 통해 삽입 insert into seat values(1, 'A-1', 0); insert into seat values(1, 'A-2', 0); ...... insert into seat values(1, 'A-23', 0); ...... insert into seat values(3, 'C-23', 0); /* 기념품 (정보) 삽입 */ insert into memento values (1, '모자', 10000); insert into memento values (1, '담요', 10000); insert into memento values (1, '슬리퍼', 10000); 상영관번호 좌석번호 예약여부 1 A-1 0 2 A-2 0 3 A-3 0 …. ….. …… /* 상영일정 (정보) 삽입 */ insert 상영일정번호 into schedule 상영일자 values(영화번호 1, to_date(상영관번호 20141231, 'yyyy-mm-dd'), 1, 1); insert into schedule values(2, to_date(20140101, 'yyyy-mm-dd'), 2, 2); insert into schedule values(3, to_date(20140102, 'yyyy-mm-dd'), 3, 3); 1 20141231 1 1 2 20140101 2 2 간식번호 종류 이름 가격 1 팝콘 치즈맛팝콘 5000 2 팝콘 양파맛팝콘 5000 3 팝콘 고소한맛팝콘 5000 4 팝콘 카라멜맛팝콘 5000 5 음료 콜라 3000 6 음료 사이다 3000 7 음료 에이드 3000 기념품번호 이름 가격 1 모자 10000 2 담요 10000 3 슬리퍼 10000
  • 23. 2-3. DB설계 23 /* customer_UID를 위한 sequence 생성 */ create sequence customer_UID; /* ticket_UID를 위한 sequence 생성 */ create sequence ticket_UID; /* 티켓 생성! */ // 자바 코드를 통해 생성 try { String query = "select schedule_uid, seat.theater_uid, seat_uid from schedule, seat where schedule.theater_uid = seat.theater_uid"; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(query); while(rs.next()){ String inQuery = "insert into ticket values (ticket_uid.nextval, " + rs.getInt(1) + ", " + rs.getInt(2) + ", '" + rs.getString(3) + "', 8000)"; Statement inStmt = con.createStatement(); ResultSet inRs = inStmt.executeQuery(inQuery); } } catch(SQLException e) { e.printStackTrace(); } /* 예매를 위한 sequence 생성 */ create sequence reservation_uid; /* 결제를 위한 sequence 생성 */ create sequence payment_UID;
  • 24. 2-3. DB설계 24 /* customer_UID를 위한 sequence 생성 */ create sequence customer_UID; /* ticket_UID를 위한 sequence 생성 */ create sequence ticket_UID; /* 티켓 생성! */ // 자바 코드를 통해 생성 try { String query = "select schedule_uid, seat.theater_uid, seat_uid from schedule, seat where schedule.theater_uid = seat.theater_uid"; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(query); while(rs.next()){ String inQuery = "insert into ticket values (ticket_uid.nextval, " + rs.getInt(1) + ", " + rs.getInt(2) + ", '" + rs.getString(3) + "', 8000)"; Statement inStmt = con.createStatement(); ResultSet inRs = inStmt.executeQuery(inQuery); } } catch(SQLException e) { e.printStackTrace(); } /* 예매를 위한 sequence 생성 */ create sequence reservation_uid; /* 결제를 위한 sequence 생성 */ create sequence payment_UID; 티켓번호 상영일정번호 상영관번호 좌석번호 가격 1 1 1 A-1 8000
  • 25. 3. 프로그램 – DB연결 25 class MovieInfo { String title; String image; } DB와 정보를 주고받을 객체 생성! class SeatInfo { String seat_UID; int issue; } class MyPayment { int total_price; String option; java.sql.Date date; int my_UID; int reservation_UID; int m_order_uid; int s_order_uid; } class Customer { String id; String pw; String name; int tel; } class Selected { String movie_title; int theater; int num_of_person; String seat; int p_snack; int p_snack_quantity; int j_snack; int j_snack_quantity; int memento; int memento_quantity; String payment_option; }
  • 26. public boolean 회원가입창아이디중복검사(String 아이디) { try { String query = "select * from customer where customer_id='"+아이디+"'"; Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(query); if(resultSet.next()) { try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; } 3-2. 프로그램 – DB연결 26
  • 27. 3-2. 프로그램 – DB연결 27 public void signUp(String id, String pw, String name, String telStr) { StringTokenizer st = new StringTokenizer(telStr, "-"); String str = ""; while(st.hasMoreTokens()) { str += st.nextToken(); } int tel = Integer.parseInt(str); try { String query = "insert into customer values (customer_uid.nextval, '"+id+"', '"+pw+"', '"+name+"', "+tel+")"; Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(query); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
  • 28. 3-2. 프로그램 – DB연결 28 public boolean 로그인창아이디검사(String 아이디) { try { String query = "select * from customer where customer_id='"+아이디+"'"; Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(query); if(resultSet.next()) { try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
  • 29. 3-2. 프로그램 – DB연결 29 public boolean 로그인창비밀번호검사(String 비밀번호) { try { String query = "select * from customer where customer_pw='"+비밀번호+"'"; Statement statement = con.createStatement(); ResultSet resultSet = statement.executeQuery(query); if(resultSet.next()) { try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { con.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
  • 30. 3-2. 프로그램 – DB연결 30 /* 로그인 되면 제일 먼저 회원 번호 가져오기! */ try { String query = "select customer_UID from customer where customer_id = '" + id +"'"; Statement statement = con.createStatement(); ResultSet rs = statement.executeQuery(query); while(rs.next()) { myPayment.my_UID = rs.getInt(1); } System.out.println("my_UID : " + myPayment.my_UID); } catch (SQLException e) { e.printStackTrace(); } /* 영화정보 가져오기! */ try { String query = "select title from movie"; Statement statement = con.createStatement(); ResultSet rs = statement.executeQuery(query); while(rs.next()) { MovieInfo mi = new MovieInfo(); mi.title = rs.getString(1); mi.image = "./images/" + mi.title + ".png"; movieInfo.add(mi); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }
  • 31. 3-2. 프로그램 – DB연결 31 /* 상영관정보 가져오기! */ try { String query = "select theater_UID from schedule where movie_UID = (select movie_UID from movie where title = '" + selected.movie_title +"')"; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(query); while(rs.next()) { selected.theater = rs.getInt(1); } System.out.println( selected.movie_title + ", " + selected.theater); } catch (SQLException e1) { e1.printStackTrace(); }
  • 32. 3-2. 프로그램 – DB연결 32 /* 좌석 정보(예약 여부) 가져오기! */ try { String query = "select seat_UID, issue from seat where theater_UID = " + selected.theater; Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(query); rs.last(); seatInfo = new SeatInfo[rs.getRow()]; rs.beforeFirst(); while(rs.next()){ char[] tmp_uid = rs.getString(1).toCharArray(); String tmpStr = ""; for (int i = 2; i < tmp_uid.length; i++) { tmpStr += tmp_uid[i]; } int seatInfoIndex = (int)((tmp_uid[0])-'A')*24 + Integer.parseInt(tmpStr); seatInfo[seatInfoIndex] = new SeatInfo(); seatInfo[seatInfoIndex].seat_UID = rs.getString(1); seatInfo[seatInfoIndex].issue = rs.getInt(2); } // 예약 좌석에 해당하는 JCheckBox 끄기! for (int i = 0; i < seatInfo.length; i++) { if (seatInfo[i].issue == 1) { seat[(int)(i/24)][i%24].setEnabled(false); } } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }
  • 33. 3-2. 프로그램 – DB연결 33 // 간식 (팝콘류, 음료류) 가져오기! try { String query = "select name, price from snack where type = '팝콘'"; Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIV E, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(query); rs.last(); listP = new String[rs.getRow() + 1]; popcornPrice = new int[rs.getRow() + 1]; rs.beforeFirst(); listP[0] = "팝콘"; popcornPrice[0] = 0; int listIndex = 0; while(rs.next()) { listP[++listIndex] = rs.getString(1); popcornPrice[listIndex] = rs.getInt(2); } query = "select name, price from snack where type = '음료'"; rs = stmt.executeQuery(query); rs.last(); listJ = new String[rs.getRow() + 1]; juicePrice = new int[rs.getRow() + 1]; rs.beforeFirst(); listJ[0] = "음료"; juicePrice[0] = 0; listIndex = 0; while(rs.next()) { listJ[++listIndex] = rs.getString(1); juicePrice[listIndex] = rs.getInt(2); } } catch(SQLException e) { e.printStackTrace(); }
  • 34. 3-2. 프로그램 – DB연결 34 // 기념품 가져오기! try { String query = "select name from memento"; Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(query); rs.last(); listS = new String[rs.getRow() + 1]; rs.beforeFirst(); listS[0] = "기념품"; int listIndex = 1; while(rs.next()) { listS[listIndex++] = rs.getString(1); } } catch(SQLException e) { e.printStackTrace(); }
  • 35. 3-2. 프로그램 – DB연결 35 if ((selected.p_snack >0 || selected.j_snack >0)) { String p_order = (selected.p_snack>0?""+selected.p_snack:"null") + ", null"; String j_order = (selected.j_snack>0?""+selected.j_snack:"null") + ", null"; // 스낵 주문정보를 DB에 추가 query = "insert into snack_order values “ + "(snack_order_uid.nextVal, " + p_order + ", " + j_order + ")"; rs = stmt.executeQuery(query); // 주문번호 바로 가져오기! query = "select s_order_uid from snack_order"; rs = stmt.executeQuery(query); rs.last(); myPayment.s_order_uid = rs.getInt(1); } else { myPayment.s_order_uid = -1; }
  • 36. 3-2. 프로그램 – DB연결 36 if ((selected.p_snack >0 || selected.j_snack >0)) { String p_order = (selected.p_snack>0?""+selected.p_snack:"null") + ", null"; String j_order = (selected.j_snack>0?""+selected.j_snack:"null") + ", null"; // 스낵 주문정보를 DB에 추가 query = "insert into snack_order values “ + "(snack_order_uid.nextVal, " + p_order + ", " + j_order + ")"; rs = stmt.executeQuery(query); // 주문번호 바로 가져오기! query = "select s_order_uid from snack_order"; rs = stmt.executeQuery(query); rs.last(); myPayment.s_order_uid = rs.getInt(1); } else { myPayment.s_order_uid = -1; } 주문번호 팝콘간식번호 팝콘주문수량 음료간식번호 음료주문수량 141201 001 2 002 3
  • 37. 4. 조원 역할 37 if (selected.memento >0) { // 기념품 주문정보를 DB에 추가 query = "insert into memento_order values " + "(memento_order_uid.nextVal, " + selected.memento + ", " + selected.memento_quantity +")"; rs = stmt.executeQuery(query); // 주문정보 바로 가져오기! query = "select m_order_uid from memento_order"; rs = stmt.executeQuery(query); rs.last(); myPayment.m_order_uid = rs.getInt(1); } else { myPayment.m_order_uid = -1; }
  • 38. 4. 조원 역할 38 if (selected.memento >0) { // 기념품 주문정보를 DB에 추가 query = "insert into memento_order values " + "(memento_order_uid.nextVal, " + selected.memento + ", " + selected.memento_quantity +")"; rs = stmt.executeQuery(query); // 주문정보 바로 가져오기! query = "select m_order_uid from memento_order"; rs = stmt.executeQuery(query); rs.last(); myPayment.m_order_uid = rs.getInt(1); } else { myPayment.m_order_uid = -1; } 주문번호 기념품번호 기념품주문수량 241217 002 3
  • 39. 4. 조원 역할 39 // 예약할 좌석을 예약상태로 바꾼 뒤, 티켓번호를 알아낸다. int[] ticket_UID = new int[4]; for (int i = 0; i < selected_seat.length; i++) { System.out.println(selected.theater + ", " + selected_seat[i]); query = "update seat set issue = 1 where theater_UID = " + selected.theater + " and seat_UID = '" + selected_seat[i]+ "'"; rs = stmt.executeQuery(query); /* 커밋한번 해준다. */ query = "commit"; rs = stmt.executeQuery(query); query = "select ticket_UID from ticket where theater_UID = " + selected.theater + " and seat_UID = '" + selected_seat[i] + "'"; rs = stmt.executeQuery(query); while(rs.next()) ticket_UID[i] = rs.getInt(1); }
  • 40. 4. 조원 역할 40 // 예매정보를 DB에 추가하고 예매번호를 확인한다. query = "insert into reservation values " + "(reservation_uid.nextval, " + ticket_UID[0] +", “ + (ticket_UID[1]>0?ticket_UID[1]:null) +", " + (ticket_UID[2]>0?ticket_UID[2]:null) +", “ + (ticket_UID[3]>0?ticket_UID[3]:null) +")"; rs = stmt.executeQuery(query); /* 커밋한번 해준다. */ query = "commit"; rs = stmt.executeQuery(query); query = "select reservation_uid from reservation"; rs = stmt.executeQuery(query); rs.last(); myPayment.reservation_UID = rs.getInt(1);
  • 41. 4. 조원 역할 41 // 예매정보를 DB에 추가하고 예매번호를 확인한다. query = "insert into reservation values " + "(reservation_uid.nextval, " + ticket_UID[0] +", “ + (ticket_UID[1]>0?ticket_UID[1]:null) +", " + (ticket_UID[2]>0?ticket_UID[2]:null) +", “ + (ticket_UID[3]>0?ticket_UID[3]:null) +")"; 예매 번호 티켓1 번호 티켓2 번호 티켓3 번호 티켓4 번호 371217 1001 1010 1011 1100 rs = stmt.executeQuery(query); /* 커밋한번 해준다. */ query = "commit"; rs = stmt.executeQuery(query); query = "select reservation_uid from reservation"; rs = stmt.executeQuery(query); rs.last(); myPayment.reservation_UID = rs.getInt(1);
  • 42. 4. 조원 역할 42 // 최종 결제 정보를 DB에 추가 try { String query = "insert into payment values (payment_uid.nextVal, " + myPayment.total_price + ", '" + myPayment.option + "', to_date('" + today + "', 'MM-DD-YYYY'), " + myPayment.my_UID + ", " + (myPayment.m_order_uid>0?myPayment.m_order_uid:null) + ", " + (myPayment.s_order_uid>0?myPayment.s_order_uid:null) + ", " + myPayment.reservation_UID + ")"; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(query); } catch(SQLException exception) { exception.printStackTrace(); }
  • 43. 4. 조원 역할 43 // 최종 결제 정보를 DB에 추가 try { String query = "insert into payment values (payment_uid.nextVal, " + myPayment.total_price + ", '" + myPayment.option + "', to_date('" + today + "', 'MM-DD-YYYY'), " + myPayment.my_UID + ", " + (myPayment.m_order_uid>0?myPayment.m_order_uid:null) + ", " + (myPayment.s_order_uid>0?myPayment.s_order_uid:null) + ", " + myPayment.reservation_UID + ")"; Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(query); } catch(SQLException exception) { exception.printStackTrace(); } 결결제제번번호호 총총 가가격격 결결제제 방방법법 결결제제 일일자자 회회원원 번번호호 기기념념품품주주문문번번호호 간간식식주주문문번번호호 예예매매번번호호 941214 27000 카드 20141207 0 241217 141201 371217
  • 44. 4. 결과물 44 프로그램 실행
  • 45. 5. 연동하면서 특별히 어려웠던 점 45 1. 자바 연동 전, 테이블에 대량의 데이터를 삽입할 때 → Excel을 이용하여 데이터 삽입! (정보 링크 : here) 2. Oracle DB와 JAVA간의 한글 깨짐 현상과 날짜형식이 맞지 않았다. → 캐릭터 셋을 확인하고 변경! (NLS_CHARACTERSET이 KO16KSC5601인지 확인!) → 날짜 형식 변경 (alter session set nls_date_format='yyyymmdd hh24:mi:ss';)
  • 46. 6. 각 조원의 역할은? 46 1. 최명근 : 프로그램 작성, DB 테이블 작성 2. 서진영 : DB 설계 공부 3. 이성광 : DB 설계 공부 & 테이블 작성 4. 방소영 : 프로그램 작성, PPT 작성 5. 전유진 : DB설계, 프로그램-DB연동, PPT 작성
  • 47. 47