728x90
반응형
728x90
반응형

 

Uncaught ReferenceError: $ is not defined 에러 이유 jQuery js가 로딩이 안됨 > import 실패

 

 

에러 사진

 

<Body>태그와 </Body>태그 사이에 코드를 적용하면 문제가 해결 된다.

1
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

 

 

 

 

728x90
반응형
728x90
반응형

 

Oracle 행개수 제한하

 

테이블 조회시 행개수 제한하고 싶을 경우

WHERE 조건문에서 ROWNUM을 사용하여 원하는 개수만 조회할 수 있다

 

N개의 행만 조회하기

SELECT 컬럼명 FROM 테이블이름 WHERE ROWNUM <= N

1개일경우 [= ]만 사용가능

 

Example

WARNING_LOG 테이블의 데이터 조회 사진(행개수 3개)

 

행개수 2개로 제한하기

SELECT 컬럼명 FROM 테이블명 WHERE ROWNUM <= 2

 

 

728x90
반응형

'DB > Oracle' 카테고리의 다른 글

[Oracle] Object Select Example  (0) 2019.08.25
[Oracle] ALTER Table Column ADD, MODIFY, DROP, RENAME Example  (0) 2019.08.25
[Oracle] Update Example  (0) 2019.07.21
[Oracle] LPAD, RPAD 함수 Example  (0) 2019.07.21
[Oracle] Null, Not Null Check Example  (0) 2019.07.07
728x90
반응형

 

Oracle에서 Table내의 데이터가 Null 이거나 Null이 아닌 데이터만 조회하고 싶을 때

== 과 != 아닌 IS IS NOT을 사용한다.

 

1. 테이블의 컬럼데이터가 널인 값 찾기

SELECT *

FROM 테이블이름

WHERE 컬럼명 IS NULL

 

2. 테이블의 컬럼데이터가 널이 아닌 값 찾기

SELECT *

FROM 테이블이름

WHERE 컬럼명 IS NOT NULL

 

EXAMPLE

WARNING_LOG 테이블의 데이터 조회 사진

 

WARNING_LOG 테이블의 W_CAUSE컬럼의 데이터가 널인 값 조회 사진

W_CAUSE의 NULL인 데이터가 없어서 결과가 아무것도 나오지 않음

 

WARNING_LOG 테이블의 W_CAUSE컬럼의 데이터가 널이 아닌 값 조회 사진

728x90
반응형

'DB > Oracle' 카테고리의 다른 글

[Oracle] Object Select Example  (0) 2019.08.25
[Oracle] ALTER Table Column ADD, MODIFY, DROP, RENAME Example  (0) 2019.08.25
[Oracle] Update Example  (0) 2019.07.21
[Oracle] LPAD, RPAD 함수 Example  (0) 2019.07.21
[Oracle] Row 개수 제한 Example  (0) 2019.07.07
728x90
반응형

 

ArrayList Object 오름차순 정렬

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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
 
public class Ascending_Obj_Sort {
    public static void main(String[] args) {
 
        ArrayList<Test> data = new ArrayList<Test>();
        
        /*임의로 Test 객체 데이터 삽입*/
        data.add(new Test("name3"3));
        data.add(new Test("name1"7));
        data.add(new Test("name2"5));
        
        /*Test Class 변수 Name 기준 오름차순 정렬하기*/
        NameAscending nameAscending = new NameAscending();
        Collections.sort(data, nameAscending);
        
        for (Test temp : data) {
            System.out.print(temp + " ");
        }
        System.out.println("\n");
 
        /*Test Class 변수 Point 기준 오름차순 정렬하기*/
        PointAscending pointAscending = new PointAscending();
        Collections.sort(data, pointAscending);
 
        for (Test temp : data) {
            System.out.print(temp + " ");
        }
        System.out.println();
 
    }
}
 
/*Test객체의 name을 기준으로 오름차순 정렬하기*/
class NameAscending implements Comparator<Test> {
 
    @Override
    public int compare(Test a, Test b) {
        
        String temp1 = a.getName();
        String temp2 = b.getName();
        
        return temp1.compareTo(temp2);
        /*return a.getName().compareTo(b.getName());*/
    }
}
 
/*Test객체의 Point를 기준으로 오름차순 정렬하기*/
class PointAscending implements Comparator<Test> {
 
    @Override
    public int compare(Test a, Test b) {
        Integer temp1 = a.getPoint();
        Integer temp2 = b.getPoint();
        
        return temp1.compareTo(temp2);
    }
}
 
class Test {
    private String name;
    private int point;
 
    public Test(String name, int point) {
        this.name = name;
        this.point = point;
    }
 
    public String getName() {
        return this.name;
    }
 
    public int getPoint() {
        return point;
    }
 
    @Override
    public String toString() {
        return "[name=" + name + ", point=" + point + "]";
    }
    
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

 

첫번째 Console Result : name 변수 기준 오름차순 정렬 결과

두번째 Console Result : Point 변수 기준 오름차순 정렬 결과

 

 

ArrayList Object 내림차순 정렬

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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
 
public class Descending_Obj_Sort {
    public static void main(String[] args) {
 
        ArrayList<Test> data = new ArrayList<Test>();
        
        /*임의로 Test 객체 데이터 삽입*/
        data.add(new Test("name3"3));
        data.add(new Test("name1"7));
        data.add(new Test("name2"5));
        
        /*Test Class 변수 Name 기준 내림차순 정렬하기*/
        NameDecending nameDecending = new NameDecending();
        Collections.sort(data, nameDecending);
        
        for (Test temp : data) {
            System.out.print(temp + " ");
        }
        System.out.println("\n");
 
        /*Test Class 변수 Point 기준 내림차순 정렬하기*/
        PointDecending pointDecending = new PointDecending();
        Collections.sort(data, pointDecending);
 
        for (Test temp : data) {
            System.out.print(temp + " ");
        }
        System.out.println();
 
    }
}
 
/*Test객체의 name을 기준으로 내림차순 정렬하기*/
class NameDecending implements Comparator<Test> {
 
    @Override
    public int compare(Test a, Test b) {
        
        String temp1 = a.getName();
        String temp2 = b.getName();
        
        return temp2.compareTo(temp1);
        /*return b.getName().compareTo(a.getName());*/
    }
}
 
/*Test객체의 Point를 기준으로 내림차순 정렬하기*/
class PointDecending implements Comparator<Test> {
 
    @Override
    public int compare(Test a, Test b) {
        Integer temp1 = a.getPoint();
        Integer temp2 = b.getPoint();
        
        return temp2.compareTo(temp1);
    }
}
 
class Test {
    private String name;
    private int point;
 
    public Test(String name, int point) {
        this.name = name;
        this.point = point;
    }
 
    public String getName() {
        return this.name;
    }
 
    public int getPoint() {
        return point;
    }
 
    @Override
    public String toString() {
        return "[name=" + name + ", point=" + point + "]";
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter

 

첫번째 Console Result : name 변수 기준 내림차순 정렬 결과

두번째 Console Result : Point 변수 기준 내림차순 정렬 결과

 

 

ForEach문에서 Temp로 변수내용이 출력되는 이유

→ Test Class의 toString 메소드에 의해 출력

public String toString() {

        return "[name=" + name + ", point=" + point + "]";

}

728x90
반응형
728x90
반응형

 

ArrayList 오름차순 정렬 

방법 1

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
import java.util.ArrayList;
import java.util.Collections;
 
public class Ascending_Sort {
    public static void main(String[] args) {
 
        ArrayList<Integer> data = new ArrayList<Integer>();
 
        /* 임의로 데이터 삽입 */
        data.add(3);
        data.add(7);
        data.add(5);
 
        /* Default Ascending Sort */
        Collections.sort(data); 
 
        output(data);
    }
 
    private static void output(ArrayList<Integer> data) {
        int size = data.size();
        for (int i = 0; i < size; i++) {
            System.out.print(data.get(i) + " ");
        }
        System.out.println();
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter

 

방법 2

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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
 
public class Ascending_Sort {
    public static void main(String[] args) {
 
        ArrayList<Integer> data = new ArrayList<Integer>();
 
        /* 임의로 데이터 삽입 */
        data.add(3);
        data.add(7);
        data.add(5);
 
        Ascending ascending = new Ascending();
        Collections.sort(data, ascending);
 
        output(data);
    }
 
    private static void output(ArrayList<Integer> data) {
        int size = data.size();
        for (int i = 0; i < size; i++) {
            System.out.print(data.get(i) + " ");
        }
        System.out.println();
    }
}
 
/* 오름차순 정렬 */
class Ascending implements Comparator<Integer> {
 
    @Override
    public int compare(Integer a, Integer b) {
        return a.compareTo(b);
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter

 

ArrayList 내림차순 정렬

 

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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
 
public class Descending_Sort {
    public static void main(String[] args) {
 
        ArrayList<Integer> data = new ArrayList<Integer>();
 
        /* 임의로 데이터 삽입 */
        data.add(3);
        data.add(7);
        data.add(5);
 
        Descending descending = new Descending();
        Collections.sort(data, descending);
 
        output(data);
    }
 
    private static void output(ArrayList<Integer> data) {
        int size = data.size();
        for (int i = 0; i < size; i++) {
            System.out.print(data.get(i) + " ");
        }
        System.out.println();
    }
}
 
/* 내림차순 정렬 */
class Descending implements Comparator<Integer> {
 
    @Override
    public int compare(Integer a, Integer b) {
        return b.compareTo(a);
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
728x90
반응형
728x90
반응형

 

OOP란?

흔히 말하는 OOP는 Object Oriented Programming의 줄임말로 객체지향 프로그래밍이다.

 

OOP의 특징 4가지

  • 캡슐화
  • 추상화
  • 다형성
  • 상속성

이러한 특징을 이용해

코드의 재사용성을 증가하고

유지보수를 쉽게 하기 위해 객체지향적으로 프로그래밍을 한다고 보면 된다.

 

캡슐화 (Encapsulation)

캡슐화란 쉽게 말하면 캡슐처럼 감싸는 개념이다.

객체의 변수, 메소드등 실제 구현 내용을 보이지 않게 감싸는 개념이다.

따라서, 외부 객체가 함부로 내부 객체를 건드리지 못하게 하는 것이다.

쉽게 예를 들자면 변수 앞에 private을 선언하는 것을 떠올리면 될 거 같다.

 

추상화 (Abstraciton)

추상화란 공통의 속성이나 기능을 묶어 이름을 붙이는 것이다.

쉽게 예를 들자면 삼각형, 사각형, 원이라는 객체가 있을 때

이 객체들을 하나로 묶을 때 객체들의 공통 특징인 도형으로 묶어 이름을 붙이는 것을 추상화라고 한다.

 

다형성 (Polymorphism)

하나의 객체가 여러 가지 타입을 가질 수 있는 것을 의미한다.

상위 클래스의 참조 변수가 하위 클래스의 객체를 참조하게 하는 것이다

오버로딩, 오버라이딩, 업캐스팅, 다운캐스팅, 인터페이스, 추상메소드, 추상클래스 방법이 있다고 생각하면 된다.

 

상속성 (Inheritance)

상위 클래스의 속성(변수)과 기능(메소드)을 (재사용하여(상속)) 하위 클래스가 전부 물려받는 것이다.

물려받은 거 외에 속성과 기능을 추가할 수 있다.

 

 

728x90
반응형
728x90
반응형

 

쉘 정렬 알고리즘

쉘 정렬(Selection Sort) 알고리즘은 삽입정렬을 보완 알고리즘입니다.

  • 가장 오래된 정렬 알고리즘의 하나
  • 전체 원소를 일정 간격(Interval)으로 분할
  • 서브 리스트들은 각자 정렬
  • 간격이 1이 될때 까지 진행

 

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
import java.util.Random;
 
public class Shell_Sort {
 
    public static void main(String[] args) {
        
        Random rnd=new Random();
        int size=16;
        int[] arr=new int[size];
        
        System.out.printf("정렬 전 원소 (%d)개: ",size);
        for(int i=0; i<size; i++) {
            arr[i]=rnd.nextInt(99)+1;
            System.out.print(arr[i]+" ");
        }
        System.out.println();
//        int[] arr = { 10, 50, 80, 90, 70 };
 
        shell_Sort(arr);
    }
 
    private static void shell_Sort(int[] arr) {
 
        int arrSize = arr.length;
        int interval = arrSize / 2;
 
        while (interval >= 1) {
            for (int i = 0; i < interval; i++) {
                intervalSort(arr, i, arrSize - 1, interval);
 
            }
            output(arr, interval);
            interval /= 2;
            
        }
    }
 
    private static void intervalSort(int[] arr, int start, int end, int interval) {
 
        for (int i = start + interval; i <= end; i += interval) {
            int item = arr[i];
            int j = 0;
            for (j = i - interval; j >= start && item < arr[j]; j -= interval) {
                // arr[j]의 값이 크니까 삽입
                arr[j + interval] = arr[j];
            }
            //삽입 끝낫으니 기억해둔 값 삽입
            arr[j + interval] = item;
        }
    }
 
    private static void output(int[] arr,int interval) {
        
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println("인터벌 : "+ interval);
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter

 

수행 결과 Java Console 창

 

728x90
반응형
728x90
반응형

 

버블 정렬 알고리즘

버블 정렬(Bubble Sort) 알고리즘은 원소가 뒤에서 부터 정렬되는 알고리즘입니다.

  • 인접한 두 원소를 검사하여 정렬하는 알고리즘
  • 간단한 알고리즘
  • 성능 향상 알고리즘으로 준비
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
public class Bubble_Sort {
    public static void main(String[] args) {
        
        int[] arr = { 1050809070 };
        // 배열의 길이 -1
        int size = arr.length -1
        boolean flag;
        
        for (int i = 0; i < size; i++) {
            
            // 교환이 있었는지 체크하는 변수
            flag = false
            
            // 맨 뒤 부터 정렬 되기 때문 i만큼 뺀다
            for (int j = 0; j < size - i; j++) { 
                if (arr[j] > arr[j + 1]) {
                    
                    // 교환이 발생하여 true 로 변경
                    flag = true;
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1= temp;
                }
            }
            
            // 원소 교환이 없으므로 정렬을 더 이상 할 필요 없다.
            if (flag == false) {
                break;
            }
        }
        output(arr);
    }
 
    private static void output(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4f; text-decoration:none">Colored by Color Scripter
728x90
반응형

+ Recent posts