# nav 사용법 알아보기


- class = "nav" // nav 명시 

- class = "nav-item" // 항목추가

- class = "nav-link" // 항목추가



# body 코드 부분

<!-- nav 적용  -->
    <ul class="nav bg-light">
        <li class="nav-item">
            <a class="nav-link active" href="#">Home</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Link1</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Link2</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Link3</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Link4</a>
        </li>
        <li class="nav-item">
            <a class="nav-link disabled" href="#">Disabled</a>
        </li>
    </ul>

    <script>
        $(function () {
            // actvie 활성화 
            $(".nav-item > .active").css("color", "red");
            
            $('.nav-link').click(function () {
                // .nav-link 클릭시 이전의 active 값 해제 후, 
                $(".nav-item > .active").css("color", "#007bff");
                $('.nav-link').removeClass('active');

                // 클릭한 위치 active 적용 
                $(this).addClass('active');
                $(".nav-item > .active").css("color", "red");
            });
        });
    </script>

# 전체코드

...더보기

<!doctype html>

<html lang="en">

 

<head>

    <!-- Required meta tags -->

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

 

    <!-- Bootstrap CSS -->

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"

        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

 

    <title>Hello, world!</title>

    <!-- Optional JavaScript -->

    <!-- jQuery first, then Popper.js, then Bootstrap JS -->

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"

        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"

        crossorigin="anonymous"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"

        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"

        crossorigin="anonymous"></script>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"

        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"

        crossorigin="anonymous"></script>

</head>

 

<body>

    <!-- nav 적용  -->

    <ul class="nav bg-light">

        <li class="nav-item">

            <a class="nav-link active" href="#">Home</a>

        </li>

        <li class="nav-item">

            <a class="nav-link" href="#">Link1</a>

        </li>

        <li class="nav-item">

            <a class="nav-link" href="#">Link2</a>

        </li>

        <li class="nav-item">

            <a class="nav-link" href="#">Link3</a>

        </li>

        <li class="nav-item">

            <a class="nav-link" href="#">Link4</a>

        </li>

        <li class="nav-item">

            <a class="nav-link disabled" href="#">Disabled</a>

        </li>

    </ul>

 

    <script>

        $(function () {

            // actvie 활성화 

            $(".nav-item > .active").css("color""red");

            

            $('.nav-link').click(function () {

                // .nav-link 클릭시 이전의 active 값 해제 후, 

                $(".nav-item > .active").css("color""#007bff");

                $('.nav-link').removeClass('active');

 

                // 클릭한 위치 active 적용 

                $(this).addClass('active');

                $(".nav-item > .active").css("color""red");

            });

        });

    </script>

</body>

 

</html>

블로그 이미지

미나미나미

,

# 점보트론(jumbotron) 사용하기


- <div class="jumbotron">

   : 테두리가 라운드가 있는 점보트론 

- <div class="jumbotron jumbotron-fluid">

    : 테두리가 직각으로 적용되어있고, 전체화면을 사용할때 적용 

 


# 테스트코드

<!-- bootstrap의 container을 사용 -->
    <div class="mt-3"></div>

    <div class="jumbotron mx-4">
        <div class="container">
            <h1>jumbotron Tutorial</h1>
            <p>이 곳에 jumbotron의 경우 round가 적용되어있습니다.</p>
            <p>containr를 사용</p>
        </div>
    </div>

    <div class="jumbotron mx-4">
        <div class="container-fluid">
            <h1>jumbotron Tutorial</h1>
            <p>이 곳에 jumbotron의 경우 round가 적용되어있습니다.</p>
            <p>containr-fluid를 사용</p>
        </div>
    </div>

    <!-- 수평선 긋기 -->
    <hr class="my-2">
    <div class="jumbotron jumbotron-fluid mx-4">
        <div class="container">
            <h1>jumbotron jumbotron-fluid Tutorial</h1>
            <p>이 곳에 jumbotron의 경우 round가 적용되어있지 않습니다.</p>
            <p>containr를 사용</p>
        </div>
    </div>

    <!-- 수평선 긋기 -->
    <hr class="my-2">
    <div class="jumbotron jumbotron-fluid mx-4">
        <div class="container-fluid">
            <h1>jumbotron jumbotron-fluid Tutorial</h1>
            <p>이 곳에 jumbotron의 경우 round가 적용되어있지 않습니다.</p>
            <p>containr-fluid를 사용</p>
        </div>
    </div>


    <!-- 수평선 긋기 -->
    <hr class="my-2">

# 결과화면

 


# 전체코드

...더보기

<!doctype html>

<html lang="ko">

 

<head>

    <!-- Required meta tags -->

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

 

    <!-- Bootstrap CSS -->

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"

        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

 

    <title>Hello, world!</title>

</head>

 

<body>

    <!-- bootstrap의 container을 사용 -->

    <div class="mt-3"></div>

 

    <div class="jumbotron mx-4">

        <div class="container">

            <h1>jumbotron Tutorial</h1>

            <p>이 곳에 jumbotron의 경우 round가 적용되어있습니다.</p>

            <p>containr를 사용</p>

        </div>

    </div>

 

    <div class="jumbotron mx-4">

        <div class="container-fluid">

            <h1>jumbotron Tutorial</h1>

            <p>이 곳에 jumbotron의 경우 round가 적용되어있습니다.</p>

            <p>containr-fluid를 사용</p>

        </div>

    </div>

 

    <!-- 수평선 긋기 -->

    <hr class="my-2">

    <div class="jumbotron jumbotron-fluid mx-4">

        <div class="container">

            <h1>jumbotron jumbotron-fluid Tutorial</h1>

            <p>이 곳에 jumbotron의 경우 round가 적용되어있지 않습니다.</p>

            <p>containr를 사용</p>

        </div>

    </div>

 

    <!-- 수평선 긋기 -->

    <hr class="my-2">

    <div class="jumbotron jumbotron-fluid mx-4">

        <div class="container-fluid">

            <h1>jumbotron jumbotron-fluid Tutorial</h1>

            <p>이 곳에 jumbotron의 경우 round가 적용되어있지 않습니다.</p>

            <p>containr-fluid를 사용</p>

        </div>

    </div>



    <!-- 수평선 긋기 -->

    <hr class="my-2">

 

    <!-- Optional JavaScript -->

    <!-- jQuery first, then Popper.js, then Bootstrap JS -->

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"

        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"

        crossorigin="anonymous"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"

        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"

        crossorigin="anonymous"></script>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"

        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"

        crossorigin="anonymous"></script>

</body>

 

</html>

블로그 이미지

미나미나미

,

# Display를 사용해보자.


<!-- bootstrap의 container을 사용 -->
    <div class="container">
        <!-- 수평선 긋기 -->
        <h1>Display : 화면 표제를 깔끔하게 표현하기</h1>
        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <h1 class="display-1">display-1</h1>
        <div>(font-size: 6rem , font-weight: 300, line-height: 1.2)</div>
        
        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <h1 class="display-2">display-2</h1>
        <div>(font-size: 5.5rem; font-weight: 300; line-height: 1.2;)</div>
        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <h1 class="display-3">display-3</h1>
        <div>(font-size: 4.5rem; font-weight: 300; line-height: 1.2;)</div>
        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <h1 class="display-4">display-4</h1>
        <div>(font-size: 3.5rem; font-weight: 300; line-height: 1.2;)</div>
        <!-- 수평선 긋기 -->
        <hr class="my-2">
    </div>

# 결과화면


# 전체코드

...더보기

<!doctype html>

<html lang="en">

 

<head>

    <!-- Required meta tags -->

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

 

    <!-- Bootstrap CSS -->

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"

        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

 

    <title>Hello, world!</title>

</head>

 

<body>

    <div class="container my-2">

        <!-- 점보트론은 웹사이트의 주요 메시지를 크게 보여주는 전광판 -->

        <div class="jumbotron">

            <!-- display를 사용하며 크기를 지정 -->

            <h1 class="display-2">Hello</h1>

            <!-- 강조 문단 글-->

            <p class="lead">This is jumbotron</p>

            <!-- y축 기준으로 4만큼 여백 , 상하 여백 -->

            <hr class="my-4">

            <p>Hello , world ! Hello, Jumbortron!</p>

            <p class="lead">

                <!-- a 위치는 -->

                <a class="btn btn-primary btn-lg" href="#">GO</a>

            </p>

        </div>

    </div>

 

    <!-- Optional JavaScript -->

    <!-- jQuery first, then Popper.js, then Bootstrap JS -->

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"

        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"

        crossorigin="anonymous"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"

        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"

        crossorigin="anonymous"></script>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"

        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"

        crossorigin="anonymous"></script>

</body>

 

</html>

블로그 이미지

미나미나미

,

# 부트스트랩(Bootstrap) 공백(Spacing) 주기 


- M/P 의 의미

       - M : Margin을 의미

       - P : Padding을 의미


- t , b , l , r ,x , y  의 의미

       - t : top을 의미 

       - b : bottom을 의미

       - l : left을 의미

       - r : right을 의미

       - x : x축 -> left , right을 의미

       - y : y축 -> top , bottom을 의미


- 0, 1, 2, 3, 4, 5, auto  의 의미

       - 0 : 0

       - 1 : .25rem( font-size가 16px이면, 4px) 크기

       - 2 : .5rem( font-size가 16px이면, 8px) 크기

       - 3 : 1rem( font-size가 16px이면, 16px) 크기

       - 4 : 1.5rem( font-size가 16px이면, 24px) 크기

       - 5 : 3rem( font-size가 16px이면, 48px) 크기

       - auto : margin의 자동으로 세팅


- 0, 1, 2, 3, 4, 5, auto  의 의미

       - 0 : 0

       - 1 : .25rem( font-size가 16px이면, 4px) 크기

       - 2 : .5rem( font-size가 16px이면, 8px) 크기

       - 3 : 1rem( font-size가 16px이면, 16px) 크기

       - 4 : 1.5rem( font-size가 16px이면, 24px) 크기

       - 5 : 3rem( font-size가 16px이면, 48px) 크기

       - auto : margin의 자동으로 세팅


- n1, n2, n3, n4, n5 의 의미 

   - n : negative을 의미

       - n1 : -.25rem( font-size가 16px이면, -4px) 크기

       - n2 : -.5rem( font-size가 16px이면, -8px) 크기

       - n3 : -1rem( font-size가 16px이면, -16px) 크기

       - n4 : -1.5rem( font-size가 16px이면, -24px) 크기

       - n5 : -3rem( font-size가 16px이면, -48px) 크기


# 테스트 코드 

 <div class="container">
        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <div class="bg-secondary">margin 테스트</div>
        <div class="m-1 bg-warning"> m-1 => top, bottom, left, right에 .25rem 만큼 margin </div>
        <div class="m-3 bg-primary"> m-3 => top, bottom, left, right에 1rem 만큼 margin </div>
        <div class="m-5 bg-danger"> m-5 => top, bottom, left, right에 3rem 만큼 margin </div>

        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <div class="bg-secondary">margin X,Y 테스트</div>
        <div class="mx-3 bg-primary"> m-3 => left, right에 1rem 만큼 margin </div>
        <div class="my-3 bg-danger"> m-3 => top, bottom에 1rem 만큼 margin </div>
        
        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <div class="bg-secondary">padding 테스트</div>
        <div class="p-1 bg-warning"> p-1 => top, bottom, left, right에 .25rem 만큼 padding </div>
        <div class="p-3 bg-primary"> p-3 => top, bottom, left, right에 1rem 만큼 padding </div>
        <div class="p-5 bg-danger"> p-5 => top, bottom, left, right에 3rem 만큼 padding </div>

        <!-- 수평선 긋기 -->
        <hr class="my-2">
        <div class="bg-secondary">padding X ,Y 테스트</div>
        <div class="px-3 bg-danger"> px-3 => left, right에 1rem 만큼 padding  </div>
        <div class="py-3 bg-primary"> px-3 => top, bottom에 1rem 만큼 padding </div>
        
        <!-- 수평선 긋기 -->
        <hr class="my-2">
    </div>

# 결과화면 


# 전체코드

...더보기

<!doctype html>

<html lang="ko">

 

<head>

    <!-- Required meta tags -->

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

 

    <!-- Bootstrap CSS -->

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"

        integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

 

    <title>Hello, world!</title>

</head>

 

<body>

    <!-- bootstrap의 container을 사용 -->

    <div class="container">

        <!-- 수평선 긋기 -->

        <hr class="my-2">

        <div class="bg-secondary">margin 테스트</div>

        <div class="m-1 bg-warning"> m-1 => top, bottom, left, right에 .25rem 만큼 margin </div>

        <div class="m-3 bg-primary"> m-3 => top, bottom, left, right에 1rem 만큼 margin </div>

        <div class="m-5 bg-danger"> m-5 => top, bottom, left, right에 3rem 만큼 margin </div>

 

        <!-- 수평선 긋기 -->

        <hr class="my-2">

        <div class="bg-secondary">margin X,Y 테스트</div>

        <div class="mx-3 bg-primary"> m-3 => left, right에 1rem 만큼 margin </div>

        <div class="my-3 bg-danger"> m-3 => top, bottom에 1rem 만큼 margin </div>

        

        <!-- 수평선 긋기 -->

        <hr class="my-2">

        <div class="bg-secondary">padding 테스트</div>

        <div class="p-1 bg-warning"> p-1 => top, bottom, left, right에 .25rem 만큼 padding </div>

        <div class="p-3 bg-primary"> p-3 => top, bottom, left, right에 1rem 만큼 padding </div>

        <div class="p-5 bg-danger"> p-5 => top, bottom, left, right에 3rem 만큼 padding </div>

 

        <!-- 수평선 긋기 -->

        <hr class="my-2">

        <div class="bg-secondary">padding X ,Y 테스트</div>

        <div class="px-3 bg-danger"> px-3 => left, right에 1rem 만큼 padding  </div>

        <div class="py-3 bg-primary"> px-3 => top, bottom에 1rem 만큼 padding </div>

        

        <!-- 수평선 긋기 -->

        <hr class="my-2">

    </div>

 

    <!-- Optional JavaScript -->

    <!-- jQuery first, then Popper.js, then Bootstrap JS -->

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"

        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"

        crossorigin="anonymous"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"

        integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"

        crossorigin="anonymous"></script>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"

        integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"

        crossorigin="anonymous"></script>

</body>

 

</html>

블로그 이미지

미나미나미

,

# JSON 값 넣기 : https://minaminaworld.tistory.com/133

 

[DB] postgreSQL json - insert 하기

# 테이블 구조 - index : 인덱스 값 - 형식serial, - stuName : 학생 이름 - varchar , - stuGrade : 학생 학년 - varchar, - stuInfo : 학생 정보 - json -- Drop table -- DROP TABLE "testGroup".teststudentin..

minaminaworld.tistory.com


# 테이블 구조 

       - index  : 인덱스 값 - 형식serial,

       - stuName : 학생 이름 - varchar ,

       - stuGrade : 학생 학년 - varchar,

       - stuInfo : 학생 정보 - json

 

-- Drop table

-- DROP TABLE "testGroup".teststudentinfo;

CREATE TABLE "testGroup".teststudentinfo (
	"index" serial NOT NULL,
	"stuName" varchar NULL,
	"stuGrade" varchar NULL,
	"stuInfo" json NULL
);

-- Permissions

ALTER TABLE "testGroup".teststudentinfo OWNER TO postgres;
GRANT ALL ON TABLE "testGroup".teststudentinfo TO postgres;


# 학생 중에서 4학년인 경우 stuinfo(json) graduteCheck : true 추가.

     - 중복 되는 항목이 없기 떄문에, 추가가 된다.

update "testGroup".teststudentinfo set
	"stuInfo" = "stuInfo"::jsonb || '{"graduteCheck" : "true"}'
where "stuGrade" = '4';


 

 

# 학생 중에서 stuinfo. major가 수학과인 사람을 통계학과로 전환.

       - major는 중복 되기 떄문에, 덮어쓰기가 된다.

update "testGroup".teststudentinfo set
	"stuInfo" = "stuInfo"::jsonb || '{"major" : "통계학과"}'
where "stuInfo"->>'major' = '수학과';


# 손오공이라는 학생의 전적대인 '경호학과'가 빠졌습니다. 추가합니다.

       - json에 json을 넣는 경우도 중복이 되지 않으면, 추가가 된다.

update "testGroup".teststudentinfo set
	"stuInfo" = "stuInfo"::jsonb || '{"preUnivercity" : {"major" : "경호학과"}}'
where "stuName"= '손오공';

 


 

블로그 이미지

미나미나미

,

 

# JSON 값 넣기 : https://minaminaworld.tistory.com/133

 

[DB] postgreSQL json - insert 하기

# 테이블 구조 - index : 인덱스 값 - 형식serial, - stuName : 학생 이름 - varchar , - stuGrade : 학생 학년 - varchar, - stuInfo : 학생 정보 - json -- Drop table -- DROP TABLE "testGroup".teststudentin..

minaminaworld.tistory.com


# 테이블 구조 

       - index  : 인덱스 값 - 형식serial,

       - stuName : 학생 이름 - varchar ,

       - stuGrade : 학생 학년 - varchar,

       - stuInfo : 학생 정보 - json

 

-- Drop table

-- DROP TABLE "testGroup".teststudentinfo;

CREATE TABLE "testGroup".teststudentinfo (
	"index" serial NOT NULL,
	"stuName" varchar NULL,
	"stuGrade" varchar NULL,
	"stuInfo" json NULL
);

-- Permissions

ALTER TABLE "testGroup".teststudentinfo OWNER TO postgres;
GRANT ALL ON TABLE "testGroup".teststudentinfo TO postgres;


# 학생 중에서 address가 '인천광역시'인 사람.

-- # ->> 표시를 통해서 json 내부의 값을 비교할 수 있다.
select * from "testGroup".teststudentinfo as t where t."stuInfo"->>'address' = '인천광역시';

 


# 전체 학생들의 학년과 주소만을 표시

select "index" as index, "stuName" as name, "stuInfo"->'address' as Address from "testGroup".teststudentinfo as t ;


# 학생들 중 json 값중 specific 키 값이 없는 사람들

select * from "testGroup".teststudentinfo as t where t."stuInfo" ->> 'specific' is null;


# 학생 중에 preUnivercity 값을 갖고 있는 사람 중에 경영학과인 사람

select * from "testGroup".teststudentinfo as t where t."stuInfo" -> 'preUnivercity' ->> 'major' = '경영학과';

 


 

블로그 이미지

미나미나미

,

# 테이블 구조 

       - index  : 인덱스 값 - 형식serial,

       - stuName : 학생 이름 - varchar ,

       - stuGrade : 학생 학년 - varchar,

       - stuInfo : 학생 정보 - json

-- Drop table

-- DROP TABLE "testGroup".teststudentinfo;

CREATE TABLE "testGroup".teststudentinfo (
	"index" serial NOT NULL,
	"stuName" varchar NULL,
	"stuGrade" varchar NULL,
	"stuInfo" json NULL
);

-- Permissions

ALTER TABLE "testGroup".teststudentinfo OWNER TO postgres;
GRANT ALL ON TABLE "testGroup".teststudentinfo TO postgres;

 

 


# insert 하기 

       - json 값 넣는 방법

                 -  '{ "key" :  "value" }'

       - json안에 json을 넣는 방법 :

                 -  '{ "key" :  { "key" :  "value"} }'

INSERT INTO "testGroup".teststudentinfo("stuName", "stuGrade", "stuInfo")
VALUES('강감찬', '2', '{ "address" : "서울특별시" , "major" : "수학과" }');

INSERT INTO "testGroup".teststudentinfo("stuName", "stuGrade", "stuInfo")
VALUES('허준', '1', '{ "address" : "서울특별시" , "major" : "국어국문과" }');

INSERT INTO "testGroup".teststudentinfo("stuName", "stuGrade", "stuInfo")
VALUES('세종대왕', '4', '{ "address" : "서울특별시" , "major" : "국어국문과" }');


INSERT INTO "testGroup".teststudentinfo("stuName", "stuGrade", "stuInfo")
VALUES('손오공', '4', '{ "address" : "부산광역시" , "major" : "체육학과" , "specific" : "태권도"}');

-- json 안에 json을 넣는 방법  
INSERT INTO "testGroup".teststudentinfo("stuName", "stuGrade", "stuInfo")
VALUES('손오반', '2', '{ "address" : "인천광역시" , "major" : "체육학과" , "specific" : "농구"}');


select * from "testGroup".teststudentinfo as t;

# 결과화면.

블로그 이미지

미나미나미

,

# 부록 : 자바 zip 만들기 https://minaminaworld.tistory.com/131

 

[Java] 자바 zip 파일 만들기( 파일 , 폴더 압축하기)

부록 : zip 압축 풀기. [Java] 자바 zip 압축 풀기 ( 파일 , 폴더 압축 풀기) # 자바로 zip 파일 압축 풀기. - 폴더 안에 파일과, 하위 폴더 압축해버리기. - 아래의 ZIP 파일 압축 풀기. # UnZip.java - ZIP 파일..

minaminaworld.tistory.com


# 자바로 zip 파일 압축 풀기.

 

    - 폴더 안에 파일과, 하위 폴더 압축해버리기. 

 

    - 아래의 ZIP 파일 압축 풀기.

 

 


# UnZip.java - ZIP 파일 압축 풀기

package zipUtil;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class UnZip {
	/**
	 * 압축풀기 메소드
	 * 
	 * @param zipFileName 압축파일
	 * @param directory   압축 풀 폴더
	 */
	public boolean unZip(String zipPath, String zipFileName, String zipUnzipPath) {

		// 파일 정상적으로 압축이 해제가 되어는가.
		boolean isChk = false;

		// 해제할 홀더 위치를 재조정
		zipUnzipPath = zipUnzipPath + zipFileName.replace(".zip", "");

		// zip 파일
		File zipFile = new File(zipPath + zipFileName);

		FileInputStream fis = null;
		ZipInputStream zis = null;
		ZipEntry zipentry = null;

		try {
			// zipFileName을 통해서 폴더 만들기
			if (makeFolder(zipUnzipPath)) {
				System.out.println("폴더를 생성했습니다");
			}

			// 파일 스트림
			fis = new FileInputStream(zipFile);

			// Zip 파일 스트림
			zis = new ZipInputStream(fis, Charset.forName("EUC-KR"));

			// 압축되어 있는 ZIP 파일의 목록 조회
			while ((zipentry = zis.getNextEntry()) != null) {
				String filename = zipentry.getName();
				System.out.println("filename(zipentry.getName()) => " + filename);
				File file = new File(zipUnzipPath, filename);

				// entiry가 폴더면 폴더 생성
				if (zipentry.isDirectory()) {
					System.out.println("zipentry가 디렉토리입니다.");
					file.mkdirs();
				} else {
					// 파일이면 파일 만들기
					System.out.println("zipentry가 파일입니다.");
					try {
						createFile(file, zis);
					} catch (Throwable e) {
						e.printStackTrace();
					}
				}
			}
			isChk = true;
		} catch (Exception e) {
			isChk = false;
		} finally {
			if (zis != null) {
				try {
					zis.close();
				} catch (IOException e) {
				}
			}
			if (fis != null) {
				try {
					fis.close();
				} catch (IOException e) {
				}
			}
		}
		return isChk;
	}

	/**
	 * @param folder - 생성할 폴더 경로와 이름
	 */
	private boolean makeFolder(String folder) {
		if (folder.length() < 0) {
			return false;
		}

		String path = folder; // 폴더 경로
		File Folder = new File(path);

		// 해당 디렉토리가 없을경우 디렉토리를 생성합니다.
		if (!Folder.exists()) {
			try {
				Folder.mkdir(); // 폴더 생성합니다.
				System.out.println("폴더가 생성되었습니다.");
			} catch (Exception e) {
				e.getStackTrace();
			}
		} else {
			System.out.println("이미 폴더가 생성되어 있습니다.");
		}
		return true;
	}

	/**
	 * 파일 만들기 메소드
	 * 
	 * @param file 파일
	 * @param zis  Zip스트림
	 */
	private void createFile(File file, ZipInputStream zis) throws Throwable {

		// 디렉토리 확인
		File parentDir = new File(file.getParent());
		// 디렉토리가 없으면 생성하자
		if (!parentDir.exists()) {
			parentDir.mkdirs();
		}
		FileOutputStream fos = null;
		// 파일 스트림 선언
		try {

			fos = new FileOutputStream(file);
			byte[] buffer = new byte[256];
			int size = 0;
			// Zip스트림으로부터 byte뽑아내기
			while ((size = zis.read(buffer)) > 0) {
				// byte로 파일 만들기
				fos.write(buffer, 0, size);
			}
		} catch (Throwable e) {
			throw e;
		} finally {
			if (fos != null) {
				try {
					fos.close();
				} catch (IOException e) {
				}

			}

		}

	}
}

 

 

# Main.java - ZIP 파일 압축 풀기

package Main;

//import zipUtil.CompressZip;
import zipUtil.UnZip;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {

		// 압축 파일 위치와 압축된 파일
		 String zipPath = "G:/ZIP_TEST/";
		 String zipFile = "jsmpeg-player-master.zip";

		// 압축을 해제할 위치, 압축할 파일이름
		String unZipPath = "G:/ZIP_TEST/TEST/";
		String unZipFile = "jsmpeg-player";

		System.out.println("--------- 압축 해제 ---------");
		UnZip unZip = new UnZip();
		
		// 압축 해제 
		if (!unZip.unZip(zipPath, zipFile, unZipPath)) {
			System.out.println("압축 해제 실패");
		}

//		System.out.println("--------- 압축 하기 ---------");
//		CompressZip compressZip = new CompressZip();
//
//		// 압축 하기
//		try {
//			if (!compressZip.compress("G:/ZIP_TEST/TEST/jsmpeg-player-master", unZipPath, unZipFile)) {
//				System.out.println("압축 실패");
//			}
//		} catch (Throwable e) {
//			e.printStackTrace();
//		}
	}
}

# 결과화면

블로그 이미지

미나미나미

,