19.05.18 JSP 쇼핑몰 차량 검색하기 (동영상 61강)

Back-End/JSP 2019. 5. 18. 00:12

차량 검색하기 기능 구현

 

 

RentcarDAO.java (DB연결)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package db;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Vector;
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
 
public class RentcarDAO {
 
    Connection con;
    PreparedStatement pstmt;
    ResultSet rs;
 
    // 커넥션풀을 이용한 데이터베이스 연결
 
    public void getcon() {
 
        // DB에 접속할때는 예외처리를 실시해야됨
        try {
 
            Context initctx = new InitialContext(); // 외부서버로 부터 데이터를 읽어들이는것이기 때문에 드라이버가 없을수 있어
            Context envctx = (Context) initctx.lookup("java:comp/env"); // 자바를 읽어들일수 있는 환경에서 사용 //예외처리를 해준다.
            DataSource ds = (DataSource) envctx.lookup("jdbc/pool");
            con = ds.getConnection();
            // 데이터소스에 username, url, password를 집어넣는다. 그렇게 하면 데이터소스가 커넥션을 얻어 온다.
            // jdbc/pool에 있는 데이터소스를 사용할수 있다.
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
 
        }
    }
 
    // 최신순 3대의 자동차를 리턴하는 메소드
    public Vector<CarListBean> getSelectCar() {
        // 리턴타입을 설정
        Vector<CarListBean> v = new Vector<>();
        getcon(); // 커넥션이 연결되어야 쿼리를 실행 가능
 
        try {
 
            String sql = "select * from rentcar order by no desc ";
            pstmt = con.prepareStatement(sql);
            // 쿼리 실행후 실행결과 Result리턴함
            rs = pstmt.executeQuery();
            int count = 0;
            while (rs.next())// 결과값이 끝날때까지만 실행
            {
                CarListBean bean = new CarListBean();
                bean.setNo(rs.getInt(1));
                bean.setName(rs.getString(2));
                bean.setCategory(rs.getInt(3));
                bean.setPrice(rs.getInt(4));
                bean.setUsepeople(rs.getInt(5));
                bean.setCompany(rs.getString(6));
                bean.setImg(rs.getString(7));
                bean.setInfo(rs.getString(8));
                // 벡터에 빈 클래스를 저장
                v.add(bean);
                count++;
                // 3개만 저장이 되야하기 때문..
                if (count > 3)
                    break// 반복문을 빠져나가시오.
 
            }
            con.close();
        } catch (Exception e) {// 내림차순으로 검색하는 쿼리문 작성
            e.printStackTrace();
        }
        return v;
 
    }
 
    // 카테고리별 자동차 리스트를 저장하는 메소드
    // 벡터로 받았으니 벡터로 리턴함..
    public Vector<CarListBean> getCategoryCar(int cate)
 
    {
        // 리턴타입이 벡터 객체이기 때문에 벡터 객체를 생성한다.
        Vector<CarListBean> v = new Vector<>();
 
        // 데이터를 저장할 빈 클래스 선언
        CarListBean bean = null;
 
        getcon();
 
        try {
            String sql = "select * from rentcar where category=?";
            pstmt = con.prepareStatement(sql);
 
            // ?에 값을 넣는다.
            pstmt.setInt(1, cate);
            // 결과를 리턴
            rs = pstmt.executeQuery();
            // 반복문을 돌려서 데이터를 저장
 
            while (rs.next()) { // 데이터를 저장할 빈 클래스 생성
                bean = new CarListBean();
                bean.setNo(rs.getInt(1));
                bean.setName(rs.getString(2));
                bean.setCategory(rs.getInt(3));
                bean.setPrice(rs.getInt(4));
                bean.setUsepeople(rs.getInt(5));
                bean.setCompany(rs.getString(6));
                bean.setImg(rs.getString(7));
                bean.setInfo(rs.getString(8));
                // 벡터에 빈 클래스를 저장
                v.add(bean);
 
            }
 
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        return v;
 
    }
 
}
 
cs

 

 

 

CarReserveMain.jsp (예약하기 페이지)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<%@page import="db.CarListBean"%>
<%@page import="java.util.Vector"%>
<%@page import="db.RentcarDAO"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
    <center>
 
        <!-- 데이터베이스에 연결하여 최신순 자동차 3대만 뿌려주는 데이터를 가져옴 -->
 
        <%
            RentcarDAO rdao = new RentcarDAO();
            //벡터를 이용하여 자동차데이터를 저장함
            Vector<CarListBean> v = rdao.getSelectCar();
        %>
 
        <table width="100">
            <tr height="240">
                <!-- 벡터에 저장된 이미지를 하나씩 출력해야하기 때문에 for문을 돌리고, 그 값들을 빈클래스 변수에 넣어준다. -->
                <%
                    for (int i = 1; i < v.size(); i++) {
                        CarListBean bean = v.get(i);
                %>
                <td width="333" align="center">
                    <!-- 이미지는 벡터의 0번지에 해당되는걸 가져온다. for문을 돌려 td를 출력해야 한다.--> <!-- 확장자는 이미지안에 있으므로 궂이 적지 않아도 된다. -->
                    <!-- 이미지를 누르면 바로 상세정보로 넘어갈수 있도록 하기위해  <a>태그를 걸고, No에 대한 상세정보가 출력되도록 하고
        이름을 사진밑에 출력하도록 한다. --> <a
                    href="CarReserveInfo.jsp?no=<%=bean.getNo()%>"> <img alt=""
                        src="img/<%=bean.getImg()%>" width="300" height="220">
                </a>
                    <p>
                        차량명 :
                        <%=bean.getName()%>
                </td>
 
 
                <%
                    }
                %>
            
        </table>
 
        <p>
            <font size="4" color="gray"> 차량 검색 하기 </font><br> <br> <br>
            <!-- 종류를 선택하고 검색을 하면 종류라는 데이터들 가지고 넘어가야하기 때문에 form형식을 사용한다. -->
        <form action="RentcarMain.jsp?center=CarCategoryList.jsp"
            method="post">
            <font size="3" color="gray"> <b>차량 검색 하기</b>
            </font>&nbsp;&nbsp; <select name="category">
                <option value="1">소형</option>
                <option value="2">중형</option>
                <option value="3">대형</option>
            </select>&nbsp;&nbsp; <input type="submit" value="검색"> &nbsp;&nbsp;
 
        </form>
        <button onclick="location.href='CarAllList.jsp'">전체 검색</button>
 
    </center>
</body>
 
</html>
 
cs

 

 

CarCategoryList.jsp (차 카테고리 리스트)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<%@page import="db.CarListBean"%>
<%@page import="java.util.Vector"%>
<%@page import="db.RentcarDAO"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
    <center>
        <table width="1000">
            <%
                //카테고리 분류값을 받아온다. (검색의 기준으로 삼아야하기 때문)
                //CarRserveMain페이지 에서 //select 옵션으로 준 값들을 가져온다.
                //소형=1, 중형=2 등등등
                //request.getParameter 값은 다 string 타입이기때문에 포장클래스를 사용해 타입변환을 한다.
                int category = Integer.parseInt(request.getParameter("category"));
 
                System.out.println("category");
 
                //DB연결을 위해 객체를 생성
                RentcarDAO rdao = new RentcarDAO();
 
                //값이 유동적이기 때문에 벡터로 받고, 파라미터로 받은 category (분류값들)를 매개값으로 준다.
                Vector<CarListBean> v = rdao.getCategoryCar(category);
 
                //tr을 3개씩 보여주고 다시 tr을 실행할 수 있도록 하는 변수 선언
                int j = 0;
                for (int i = 0; i < v.size(); i++) {
                    //벡터에 저장되어 있는 빈 클래스를 추출
                    CarListBean bean = v.get(i);
                    //3번마다 0이 돌아온다는 뜻. 즉 3번에 한번 실행하도록 하는 구문
                    if (j % 3 == 0) {
            %>
            <tr height="220">
                <%
                    }
                %>
                <td width="333" align="center"><a
                    href="RentcarMain.jsp?center=CarReserveInfo.jsp?no=<%=bean.getNo()%>">
                        <img alt="" src="img/<%=bean.getImg()%>" width="300" height="200">
                </a>
                    <p>
                        <font size="3" color="gray"><b>차량명 : <%=bean.getName()%>
                        </b> </font></td>
 
 
 
                <%
                    j = j + 1//j값을 증가하여 하나의 행에 총3개의 차량정보를 보여주기 위해서 증가
                    }
                %>
            
        </table>
    </center>
</body>
</html>
cs

 

 

 

 

:

HTTP 500 java.io.IOException 에러 (파라미터 관련)

Back-End/Problems 2019. 5. 17. 22:45

 

 

 

 

 

<a>태그를 사용해서 파라미터 값(url)을 넘길때 'CarReserveMain.jsp' 처럼 작은따움표 ' ' 가 들어가있어서 제대로 넘겨지지 않았었다.

:

19.05.17 JSP 쇼핑몰 차량 예약하기 (동영상 60강)

Back-End/JSP 2019. 5. 17. 15:01

CarListBean.java (빈 클래스)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package db;
 
public class CarListBean { //빈 클래스 생성함
    
    
    private int no;
    private String name;
    private int category;
    private int price;
    private int usepeople;
    private String company;
    private String img;
    private String info;
    
    
    public int getNo() {
        return no;
    }
    public void setNo(int no) {
        this.no = no;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getCategory() {
        return category;
    }
    public void setCategory(int category) {
        this.category = category;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }
    public int getUsepeople() {
        return usepeople;
    }
    public void setUsepeople(int usepeople) {
        this.usepeople = usepeople;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public String getInfo() {
        return info;
    }
    public void setInfo(String info) {
        this.info = info;
    }
    
    public String getCompany() {
        return company;
    }
    public void setCompany(String company) {
        this.company = company;
    }
}
 
cs



RentcarDAO.java (DB연결)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package db;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Vector;
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
 
public class RentcarDAO {
 
    Connection con;
    PreparedStatement pstmt;
    ResultSet rs;
 
    // 커넥션풀을 이용한 데이터베이스 연결
 
    public void getcon() {
 
        // DB에 접속할때는 예외처리를 실시해야됨
        try {
 
            Context initctx = new InitialContext(); // 외부서버로 부터 데이터를 읽어들이는것이기 때문에 드라이버가 없을수 있어
            Context envctx = (Context) initctx.lookup("java:comp/env"); // 자바를 읽어들일수 있는 환경에서 사용 //예외처리를 해준다.
            DataSource ds = (DataSource) envctx.lookup("jdbc/pool");
            con = ds.getConnection();
            // 데이터소스에 username, url, password를 집어넣는다. 그렇게 하면 데이터소스가 커넥션을 얻어 온다.
            // jdbc/pool에 있는 데이터소스를 사용할수 있다.
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
 
        }
    }
 
    // 최신순 3대의 자동차를 리턴하는 메소드
    public Vector<CarListBean> getSelectCar() {
        // 리턴타입을 설정
        Vector<CarListBean> v = new Vector<>();
        getcon(); // 커넥션이 연결되어야 쿼리를 실행 가능
 
        try {
 
            String sql = "select * from rentcar order by no desc ";
            pstmt = con.prepareStatement(sql);
            // 쿼리 실행후 실행결과 Result리턴함
            rs = pstmt.executeQuery();
            int count = 0;
            while (rs.next())// 결과값이 끝날때까지만 실행
            {
                CarListBean bean = new CarListBean();
                bean.setNo(rs.getInt(1));
                bean.setName(rs.getString(2));
                bean.setCategory(rs.getInt(3));
                bean.setPrice(rs.getInt(4));
                bean.setUsepeople(rs.getInt(5));
                bean.setCompany(rs.getString(6));
                bean.setImg(rs.getString(7));
                bean.setInfo(rs.getString(8));
                // 벡터에 빈 클래스를 저장
                v.add(bean);
                count++;
                // 3개만 저장이 되야하기 때문..
                if (count > 2)
                    break// 반복문을 빠져나가시오.
 
            }
            con.close();
        } catch (Exception e) {// 내림차순으로 검색하는 쿼리문 작성
            e.printStackTrace();
        }
        return v;
 
    }
 
}
 
cs



Bottom.jsp (하단)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<center>
    <table width="1000">
        <tr height="100">
            <td align="center">
                <hr color="red" size="5"> 이용약관 이메일 무단수집거부 개인정보 취급(처리)방침 윤리경영
                        보안신고 Contact Us 사업장 소개 사이트맵 웹접근성 도움말<br> 배드민턴단 COPYRIGHT@2015
                        SAMSUNG ELECTRO-MECHANICS, All rights reserved.
                    </td>
                </tr>
            </table>
        </center>
    </body>
</html>
cs



CarReserveMain.jsp 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<%@page import="db.CarListBean"%>
<%@page import="java.util.Vector"%>
<%@page import="db.RentcarDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
    <center>
 
        <!-- 데이터베이스에 연결하여 최신순 자동차 3대만 뿌려주는 데이터를 가져옴 -->
 
        <%
            RentcarDAO rdao = new RentcarDAO();
            //벡터를 이용하여 자동차데이터를 저장함
            Vector<CarListBean> v = rdao.getSelectCar();
        %>
 
        <table width="100">
            <tr height="240">
                <!-- 벡터에 저장된 이미지를 하나씩 출력해야하기 때문에 for문을 돌리고, 그 값들을 빈클래스 변수에 넣어준다. -->
                <%
                    for (int i = 1; i < v.size(); i++) {
                        CarListBean bean = v.get(i);
                %>
                <td width="333" align="center">
                    <!-- 이미지는 벡터의 0번지에 해당되는걸 가져온다. for문을 돌려 td를 출력해야 한다.--> <!-- 확장자는 이미지안에 있으므로 궂이 적지 않아도 된다. -->
                    <!-- 이미지를 누르면 바로 상세정보로 넘어갈수 있도록 하기위해  <a>태그를 걸고, No에 대한 상세정보가 출력되도록 하고
        이름을 사진밑에 출력하도록 한다. --> <a
                    href="CarReserveInfo.jsp?no=<%=bean.getNo()%>"> <img alt=""
                        src="img/<%=bean.getImg()%>" width="300" height="220">
                </a>
                    <p>
                        차량명 :
                        <%=bean.getName()%>
                </td>
 
 
                <%
                    }
                %>
            
        </table>
        <hr color="red" size="3">
        <p>
            <font size="4" color="gray"> </font><br> <br> <br>
            <!-- 종류를 선택하고 검색을 하면 종류라는 데이터들 가지고 넘어가야하기 때문에 form형식을 사용한다. -->
        <form action="CarCategoryList.jsp" method="post">
            <font size="3" color="gray"> <b>차량 검색 하기</b>
            </font>&nbsp;&nbsp; <select name="category">
                <option value="1">소형</option>
                <option value="2">중형</option>
                <option value="3">대형</option>
            </select>&nbsp;&nbsp; <input type="submit" value="검색"> &nbsp;&nbsp;
            <button onclick="location.href='CarAllList.jsp'">전체 검색</button>
 
        </form>
    </center>
</body>
 
</html>
cs



Center.jsp (중간)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <center>
        <table width="1000">
            <tr height="600">
                <!-- 센터에 출력될 이미지를 추가 -->
                <td align="center"><img alt="" src="img/Main.jpg" height="470"
                    width="1000"></td>
            </tr>
        </table>
    </center>
</body>
</html>
cs



RentcarMain.jsp (메인)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
 
    <%
        String center = request.getParameter("center");
        //처음 실행시에는 center 값이 넘어오지 않기에 반드시  null처리를 해야한다.
        //처리를 하지않으면 에러가 발생될수 있다.
        if (center == null) {
            center = "Center.jsp"//디폴트 center값을 부여(첫 화면에는 center이 뜨도록 한다는 말)    
        }
                    
%>
    <center>
        <table width="1000">
 
            <!-- Top 부분 -->
            <tr height="140" align="center">
                <!-- include page를 사용하여서 main페이지에서 각 페이지가 호출될수 있도록 한다. -->
                <td align="center" width="1000"><jsp:include page="Top.jsp" /></td>
            </tr>
 
            <!-- Center 부분 -->
            <!-- Top랑,Bottom은 화면이 넘어가더라도 바뀌지 않지만 center은 계속 바뀌기 때문에 center값을 준다 -->
 
            <tr align="center">
                <td align="center" width="1000"><jsp:include page="<%=center%>" />
                </td>
            </tr>
 
            <!-- Bottom 부분 -->
            <tr height="140" align="center">
                <td align="center" width="1000"><jsp:include page="Bottom.jsp" /></td>
            </tr>
 
        </table>
    </center>
</body>
</html>
cs



Top.jsp (상단)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
 
    <!-- 세션을 이용한 로그인 처리 -->
    <!-- 세션으로 받아온 값은 오브젝트 타입이기 때문에 String 타입으로 컨버팅 한다. -->
 
    <%
        String id = (String) session.getAttribute("id");
 
        //로그인이 되어있지 않다면 id에 "GUEST"값을 준다
        if (id == null) {
            id = "GUEST";
        }
    %>
 
    <table width="1000" bordercolor="white">
        <tr height="70">
            <td colspan="4">
                <!-- 이미지를 불러오기위한 태그 작성 --> <img alt="" src="img/RENT.jpg"
                height="150" width="250">
            </td>
            <td align="center" width="200"><%=id%> 님 반갑습니다.</td>
        </tr>
 
        <tr height="50">
            <td align="center" width="200" bgcolor="pink">
                <!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
                    href="RentcarMain.jsp?center='CarReserveMain.jsp'"
                    style="text-decoration: none"> 예 약 하 기 </a></font>
            </td>
 
            <td align="center" width="200" bgcolor="pink">
                <!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
                    href="#" style="text-decoration: none"> 예 약 확 인</a></font>
            </td>
 
            <td align="center" width="200" bgcolor="pink">
                <!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
                    href="#" style="text-decoration: none"> 자 유 게 시 판 </a></font>
            </td>
 
            <td align="center" width="200" bgcolor="pink">
                <!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
                    href="#" style="text-decoration: none"> 이 벤 트 </a></font>
            </td>
 
            <td align="center" width="200" bgcolor="pink">
                <!-- 글자를 누르면 화면이 넘어갈수 있도록 a태그를 걸어줌 --> <font color="white" size="5"><a
                    href="#" style="text-decoration: none"> 고 객 센 터 </a></font>
            </td>
        </tr>
 
    </table>
</body>
</html>
cs




:

개인 프로젝트 ppt 수정본

개인 공부 2019. 5. 16. 23:42

 

개발일정 (대충).xlsx

 

개인프로젝트 (H-Star Ranking).pptx

 

'개인 공부' 카테고리의 다른 글

개인프로젝트 수정본  (0) 2019.07.18
HTTP, Stateless, Stateful 정의  (0) 2019.05.30
백엔드, 프론트엔드 로드맵  (0) 2019.05.14
웹 프로그래머 포트폴리오 작성 팁  (0) 2019.05.13
공부해야될것들  (0) 2019.05.13
:

Android 학습일정

기타 프로그램/Android 2019. 5. 16. 17:04

동영상 강의 (155강)

https://www.youtube.com/watch?v=9J5Z_pyqP_s&list=PLG7te9eYUi7sj1mAKtunTzO7s_jPxez-e




Android 학습일정.xlsx






:

JavaScript 학습일정

Front-End/javascript 2019. 5. 16. 15:16



자바 스크립트 (102강짜리)

https://www.youtube.com/watch?v=PZIPsKgWJiw&list=PLuHgQVnccGMA4uSig3hCjl7wTDeyIeZVU




JavaScript 학습 일정.xlsx





'Front-End > javascript' 카테고리의 다른 글

JavaScript 숫자와 문자 -2  (0) 2019.05.22
JavaScript 숫자와 문자 -1  (0) 2019.05.22
sublimetext 설치  (0) 2019.05.22
JavaScript 실행 및 실습  (0) 2019.05.21
js(자바스크립트 파일) 만드는법  (0) 2019.05.07
:

Spring Lagacy, Boot 학습 일정

Back-End/Spring 2019. 5. 16. 14:23




Spring Lagacy, Boot 학습 일정.xlsx


Spring (Lagacy) 
30강짜리 강의 오렌지색

https://www.youtube.com/watch?v=KkMlhnEI9ds&list=PLY9pe3iUjRrRiJeg0jw22yW1G5yzAdiqC




Spring Boot 
Spring boot 백기선 40강짜리
https://www.youtube.com/results?search_query=Spring+boot+%EB%B0%B1%EA%B8%B0%EC%84%A0












'Back-End > Spring' 카테고리의 다른 글

spring 로킹툴  (0) 2019.05.28
표준 프레임워크 오픈 커뮤니티  (0) 2019.05.28
스프링의 실행 과정, 스프링의 특징  (0) 2019.05.28
Spring 설치  (0) 2019.05.27
스프링 (백기선) 학습일정, 인강  (0) 2019.05.22
:

19.05.15 jsp 쇼핑몰-차량 예약하기(동영상 59강)

Back-End/JSP 2019. 5. 15. 18:21

쇼핑몰 차량 예약하기를 누르면 <차량 종류보기> 창이 뜨도록 한다.


상위 3종류의 모델은 최신순으로 보여주게 한다.


<소형,중형,대형> 분류 검색이 되도록 한다.


<전체검색>이 되도록 한다.



img.zip


CarReserveMain.jsp (상위 3종류의 모델을 최신순으로 보여줌)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<%@page import="db.CarListBean"%>
<%@page import="java.util.Vector"%>
<%@page import="db.RentcarDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
    <!-- 데이터베이스에 연결하여 최신순 자동차 3대만 뿌려주는 데이터를 가져옴 -->
 
<%
    RentcarDAO rdao = new RentcarDAO();
    //벡터를 이용하여 자동차데이터를 저장함
    Vector<CarListBean> v = rdao.getSelectCar();
 
%>
 
</body>
</html>
cs




RentcarDAO.java (DB랑 연결)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package db;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Vector;
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
 
public class RentcarDAO {
 
    Connection con;
    PreparedStatement pstmt;
    ResultSet rs;
 
    // 커넥션풀을 이용한 데이터베이스 연결
 
    public void getcon() {
 
        // DB에 접속할때는 예외처리를 실시해야됨
        try {
 
            Context initctx = new InitialContext(); // 외부서버로 부터 데이터를 읽어들이는것이기 때문에 드라이버가 없을수 있어
            Context envctx = (Context) initctx.lookup("java:comp/env"); // 자바를 읽어들일수 있는 환경에서 사용 //예외처리를 해준다.
            DataSource ds = (DataSource) envctx.lookup("jdbc/pool");
            con = ds.getConnection();
            // 데이터소스에 username, url, password를 집어넣는다. 그렇게 하면 데이터소스가 커넥션을 얻어 온다.
            // jdbc/pool에 있는 데이터소스를 사용할수 있다.
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
 
        }
    }
 
    // 최신순 3대의 자동차를 리턴하는 메소드
    public Vector<CarListBean> getSelectCar() {
        // 리턴타입을 설정
        Vector<CarListBean> v = new Vector<>();
        getcon(); // 커넥션이 연결되어야 쿼리를 실행 가능
 
        try {
 
            String sql = "select * from rentcar order by no desc ";
            pstmt = con.prepareStatement(sql);
            // 쿼리 실행후 실행결과 Result리턴함
            rs = pstmt.executeQuery();
            int count = 0;
            while (rs.next())// 결과값이 끝날때까지만 실행
            {
                CarListBean bean = new CarListBean();
                bean.setNo(rs.getInt(1));
                bean.setName(rs.getString(2));
                bean.setCategory(rs.getInt(3));
                bean.setPrice(rs.getInt(4));
                bean.setUsepeople(rs.getInt(5));
                bean.setCompany(rs.getString(6));
                bean.setImg(rs.getString(7));
                bean.setInfo(rs.getString(8));
                // 벡터에 빈 클래스를 저장
                v.add(bean);
                count++;
                // 3개만 저장이 되야하기 때문..
                if (count > 3)
                    break// 반복문을 빠져나가시오.
 
            }
            con.close();
        } catch (Exception e) {// 내림차순으로 검색하는 쿼리문 작성
            e.printStackTrace();
        }
 
    }
 
}
 
cs



CarListBean.java (빈 클래스)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package db;
 
public class CarListBean { //빈 클래스 생성함
    
    public String getCompany() {
        return company;
    }
    public void setCompany(String company) {
        this.company = company;
    }
    private int no;
    private String name;
    private int category;
    private int price;
    private int usepeople;
    private String company;
    private String img;
    private String info;
    
    
    public int getNo() {
        return no;
    }
    public void setNo(int no) {
        this.no = no;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getCategory() {
        return category;
    }
    public void setCategory(int category) {
        this.category = category;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }
    public int getUsepeople() {
        return usepeople;
    }
    public void setUsepeople(int usepeople) {
        this.usepeople = usepeople;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public String getInfo() {
        return info;
    }
    public void setInfo(String info) {
        this.info = info;
    }
    
}
 
cs


: