package _4;

import java.util.Scanner;
import java.util.Stack;

public class Main {
	
	public static void main(String[] args) {
				
		int inputNum1;
		int inputNum2;
		int q = 0;
		Stack<Integer> st = new Stack<Integer>();
		
		Scanner sc = new Scanner(System.in);
		System.out.print("10진수 숫자입력 >> ");
		inputNum1 = sc.nextInt();		
		System.out.print("원하는 진수입력 >> ");
		inputNum2 = sc.nextInt();
		
		while(true) {
			st.add(inputNum1 % inputNum2);
			inputNum1 /= inputNum2;					
			if(inputNum1 == 1) {
				st.add(1);
				break;
			}
		}
		
		System.out.print("변환결과 >> ");
		while(!st.empty()) {
			System.out.print(st.pop());
		}		
	}
	
}

'JAVA > 프로그래머스' 카테고리의 다른 글

6. 최대공약수 GCD  (0) 2020.12.20
5. 대문자 ↔ 소문자  (0) 2020.12.20
3. 최빈수 찾기  (0) 2020.12.08
2. 피보나치  (0) 2020.12.08
1. 검색  (0) 2020.12.07
package _3;

import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int[] arr = new int[15];
		int cnt = 0;		
		int max = 0;
		HashMap<Integer, Integer> cntMap = new HashMap<Integer, Integer>();
		
		Scanner scan = new Scanner(System.in);
		System.out.print("숫자 " + arr.length + "개 입력 >> ");
		for (int i = 0; i < arr.length; i++) {
			arr[i] = scan.nextInt();
		}
		
		for (int i = 0; i < arr.length; i++) {
			int curVal = arr[i];			
			for (int j = 0; j < arr.length; j++) {				
				if(curVal == arr[j]) {
					cnt++;
				}
			}			
			if(max <= cnt) {				
				if(max == cnt) {
					max = cnt;
					cntMap.put(curVal, max);
				}else {
					max = cnt;
					cntMap.clear();
					cntMap.put(curVal, max);
				}				
			}			
			cnt = 0;
		}
		for(int key : cntMap.keySet()) {
			System.out.println(key + " : " + cntMap.get(key) + "회");
		}		
	}	
}

'JAVA > 프로그래머스' 카테고리의 다른 글

6. 최대공약수 GCD  (0) 2020.12.20
5. 대문자 ↔ 소문자  (0) 2020.12.20
4. 10진수 → N진수  (0) 2020.12.20
2. 피보나치  (0) 2020.12.08
1. 검색  (0) 2020.12.07
package _2;

import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
        // 1
		int[] arr = new int[100];
		
		arr[0] = 1;
		arr[1] = 1;
		
		Scanner scan = new Scanner(System.in);
		System.out.print("출력할 피보나치 수열 개수 : ");
		int input = scan.nextInt();
		
		for(int i = 0; i <= input; i++) {
			if(i >=2) {
				arr[i] = arr[i-1] + arr[i-2];
			}
			System.out.print(arr[i] + " ");
		}
		
		System.out.println(); /////////////////////////////////////////////
		
        // 2
		int prevprevNum = 1;
		int prevNum = 1;
		System.out.print(prevprevNum + " ");
		System.out.print(prevNum + " ");
		
		for (int i = 0; i <= 30; i++) {
			int curNum = prevprevNum + prevNum;
			System.out.print(curNum + " ");			
			
			prevprevNum = prevNum;
			prevNum = curNum;
		}		
	}	
}

'JAVA > 프로그래머스' 카테고리의 다른 글

6. 최대공약수 GCD  (0) 2020.12.20
5. 대문자 ↔ 소문자  (0) 2020.12.20
4. 10진수 → N진수  (0) 2020.12.20
3. 최빈수 찾기  (0) 2020.12.08
1. 검색  (0) 2020.12.07

학생검색

package _1;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Student st1 = new Student("철수", "111");
		Student st2 = new Student("영수", "222");
		Student st3 = new Student("민수", "333");
		
		ArrayList<Student> list = new ArrayList<Student>();
		list.add(st1);
		list.add(st2);
		list.add(st3);						
				
		Scanner scan = new Scanner(System.in);						
		
		while(true) {
			System.out.println("검색? y/n");
			String input = scan.next();								
			
			if(input.equals("y")) {
				System.out.println("검색을 시작합니다.");
				String name = scan.next();
				boolean flag = false;
				
				for(Student st : list) {
					if(st.getName().equals(name)) {						
						System.out.println("검색결과 : " + st.getNo());
						flag = true;
					}
				}
				
				if(!flag) {
					System.out.println("없음");
				}
				
			}else if(input.equals("n")) {
				break;
			}else {
				System.out.println("잘못입력 y/n");
			}
		}
		System.out.println("프로그램 종료");
	}
}

'JAVA > 프로그래머스' 카테고리의 다른 글

6. 최대공약수 GCD  (0) 2020.12.20
5. 대문자 ↔ 소문자  (0) 2020.12.20
4. 10진수 → N진수  (0) 2020.12.20
3. 최빈수 찾기  (0) 2020.12.08
2. 피보나치  (0) 2020.12.08

Apache 에러 페이지 설정

1. error.html 이름으로 원하는 에러 페이지를 만들고 서버의 특정 경로에 업로드

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ERROR</title>
  </head>
  <body>
    <h1>ERROR</h1>
  </body>
</html>

 

2. httpd.conf 설정

Alias /error/ "에러페이지가 있는 서버경로"
ErrorDocument 404 /error/error.html
ErrorDocument 403 /error/error.html

 

3. apache 재시작

 


 

Websphere 에러 페이지 설정

1. error.jsp 만들기

 

2. web.xml, web_merged.xml 설정

경로 : WebSphere/AppServer/profiles/<AppSrv01>/config/cells/<cell_name>/applications/<ear_name>/deployments/<app_name>/<war_name>/WEB-INF

* 다른 WAS는 어플리케이션에 직접 속해있는 web.xml을 수정하면 되는데, WebSphere는 실제 WebSphere가 설치된 디렉터리 안에 있는 web.xml, web_merged.xml을 수정해야 반영됨

<error-page>
	<error-code>404</error-code>
    <location>/error.jsp</location>
</error-page>
<error-page>
	<error-code>500</error-code>
	<location>/error.jsp</location>
</error-page>

 

3. WebSphere 재시작

 


 

Tomcat 에러 페이지 설정

1. error.jsp

 

2. web.xml설정

<error-page>
	<error-code>404</error-code>
    <location>/error.jsp</location>
</error-page>
<error-page>
	<error-code>500</error-code>
	<location>/error.jsp</location>
</error-page>

 

3. Tomcat 재시작

Apache의 모니터링 기능으로 서버 정보가 노출되는 취약점 조치

 

http://웹서버의IP/server-status 로 접속하면 서버의 정보가 노출됨

 

httpd.conf에서 설정할 수 있음

 

httpd.conf

ExtendStatus On : 네트워크 통신 상의 데이터도 볼 수 있음

ExtendStatus Off : 기본적인 정보만 제공, 취약점이 해결된 것은 아님

 

mod_statud모듈을 사용하지 않도록 주석 처리하면 server-status를 확인할 수 없음

#LoadModule status_module modules/mod_status.so

 

mod_status 아파치 모듈

설명 : 아파치 서버 활동과 성능에 대한 정보를 제공

Status 모듈은 서버 관리자에게 서버의 상태를 보여준다. 쉽게 읽을 수 있는 HTML 페이지로 현재 서버통계를 보여준다. 필요하다면 (표준을 따르는 브라우저에서) 페이지를 자동으로 갱신할 수 있다. 현재 서버 상태를 컴퓨터가 읽을 수 있는 간단한 목록으로 보여줄 수도 있다.

알려주는 정보는:

  • 요청을 서비스하는 worker의 개수
  • 쉬고 있는(idle) worker의 개수
  • 각 worker들의 상태, worker가 처리한 요청의 개수와 worker가 서비스한 전체 바이트수 (*)
  • 총 접근 횟수와 서비스한 바이트수 (*)
  • 서버가 시작혹은 재시작한 시간과 동작한 시간
  • 초당 요청수 평균, 초당 서비스한 바이트수와 요청당 바이트수 평균 (*)
  • 현재 아파치 전체와 각 worker들의 CPU 비율 (*)
  • 현재 처리하고 있는 호스트와 요청 (*)

httpd.apache.org/docs/2.4/ko/mod/mod_status.html

1. 원본 디렉토리 서버 설정

1) nfs 데몬 확인

lssrc -g nfs

- 데몬실행 : startsrc -f nfs / 데몬 중지 : stopsrc -g nfs

 

 

2) /etc/exports 확인

<export> <host1>(<options>) <hostN>(<options>)..

<공유할 디렉토리> <공유받을 host>, 공유 옵션(ex. rw)

 

smit nfs > 네트워크 파일 시스템 (NFS) > 반출 리스트에 디렉토리 추가 > 대체 반출 파일의 경로 이름 

여기에 추가하면 /etc/exports에 기록됨

 

3) host에 공유할 디렉토리 알림

/usr/sbin/exportfs -a

showmount -e

 

2. host서버 설정

1) 공유받을 디렉토리 생성 

mkdir 디렉토리명

 

2) 마운트 걸기

mount IP주소 or HOST명:/디렉토리명 /디렉토리명

스칼라 함수의 숫자 인수가 범위를 벗어났으므로 명령문이 실행되지 않았습니다.

 

- 하나 이상의 문자열을 조작하는 스칼라 함수에 범위밖 숫자 인수를 지정한 경우 발생

 

  • SUBSTR
  • SUBSTRING
  • LEFT
  • RIGHT
  • INSERT
  • OVERLAY
SELECT SUBSTR('',1,1) from dual;

- SUBSTR 함수에 대한 두 번째 인수는 문자열에서의 위치를 지정

- 해당 인수에 대해 지정한 값이 1보다 작거나 문자열의 길이보다 크면 에러 발생

'DATABASE > db2' 카테고리의 다른 글

[DB2] ALTER TABLE 오류  (0) 2021.07.07
[DB2] SQL State: 55019  (0) 2021.05.18
[DB2] SQLSTATE=42826, SQLCODE=-421  (0) 2020.07.15
[DB2] SQLSTATE = 22001: Error Code = -302  (0) 2020.05.07

파티션

- 파티션을 사용하면 대량 추가/변경/삭제 작업을 빠르게 처리할 수 있음

- 파티셔닝은 테이블 또는 인덱스 데이터를 특정 컬럼(파티션 키) 값에 따라 별도의 세그먼트에 나눠서 저장하는 것

- 관리적 측면 : 파티션 단위 백업, 추가, 삭제, 변경 → 가용성 향상

- 성능적 측면 : 파티션 단위 조회 및 DML, 경합 또는 부하 분산

 

Range 파티션

- 가장 기초적인 방식으로 주로 날짜 컬럼을 기준으로 시계열에 따라 파티셔닝

create 주문 ( 주문번호 number, 주문일자 varchar2(8), 고객ID varchar2(5), 
			배송일자 varchar2(8), 주문금액 number ... )
partition by range(주문일자) (
	partition by P2020_Q1 value less than ('20200101')
    ,partition by P2020_Q2 value less than ('20200201')
    ,partition by P2020_Q3 value less than ('20200301')
    ,partition by P2020_Q4 value less than ('20200401')
    ,partition by P2020_Q5 value less than ('20200501')
    ,partition by P2020_Q6 value less than ('20200601')
    ,partition by P2020_Q7 value less than ('20200701')
    ,partition by P2020_Q8 value less than ('20200801')
    ,partition by P2020_Q9 value less than ('20200901')
    ,partition by P2020_Q10 value less than ('20201001')
    ,partition by P2020_Q11 value less than ('20201101')
    ,partition by P2020_Q12 value less than (MAXVALUE) -- 주문일자 >= '20201101'
)

- 주문일자 컬럼을 기준으로 월단위 파티셔닝

- 각 레코드를 파티션 키 값에 따라 분할하여 저장하며, 조회를 할 때에도 검색 조건을 만족하는 파티셔만 골라서 읽을 수 있어서 성능 향상에 도움을 줌 (읽지 않아도 되는 파티션 세그먼트를 액세스 대상에서 제외)

 

select *
from 주문
where 주문일자 >= '20200101'
and 주문일자 < '20200501'

- 주문 테이블을 전부 Full Scan하지 않고 P2020_Q2, P2020_Q3, P2020_Q4, P2020_Q5 파티션에만 액세스하면 됨

com.ibm.db2.jcc.am.SqlSyntaxErrorException: 

집합 연산자나 VALUES절의 피연산자에 있는 컬럼 수가 동일하지 않습니다

 

- UNION ALL 같은 집합 연산자 사용 시, 위/아래 컬럼의 조합/개수 가 불일치하는 경우

- INSERT - VALUES 에서 INSERT대상 컬럼과 VALUES에 작성된 값 개수가 다른 경우

'DATABASE > db2' 카테고리의 다른 글

[DB2] ALTER TABLE 오류  (0) 2021.07.07
[DB2] SQL State: 55019  (0) 2021.05.18
[DB2] SQLSTATE=22011, SQLCODE=-138  (0) 2020.07.17
[DB2] SQLSTATE = 22001: Error Code = -302  (0) 2020.05.07