기존 방식 


function sum(a,b) {
   var c = a + b;
   return c;
}

sum(1,2); // 3

 


var sum = function (a,b) {
   var c = a + b;
   return c;
}

sum(1,2); // 3

ES6 화살표 함수

function 생략(삭제) (a,b) {  사이에 화살표를 삽입 (a,b) => {


let sum = (a,b) => {
   let c = a + b;
   return c;
};

sum(1,2); // 3

참 쉽죠 ^^

객체 함수(?) 뭔가 복잡해 보이지만 있어 보이는 함수

const  calc = { 
  sum: (a,b) => { 
    return a+b;
  }, 
  sub: (a,b) => {
    return a-b;
  } 
};

calc.sum(1,2); // 3

calc.sub(4,1); // 3

 

w3scholos.com

https://www.w3schools.com/js/js_arrow_function.asp

Posted by 비니미니파파
Server(Windows&Linux)2021. 3. 4. 10:55

date 란 명령어를 사용할 수 있습니다.

date - 시스템 시간과 날짜를 출력/설정한다.

~]# date
2021. 03. 04. (목) 10:50:59 KST

date +'%Y-%m-%d' 형식으로 포맷을 설정 할 수 도 있습니다.

~]# date +'%Y-%m-%d'
2021-03-04

 

 

쉘스크립트(shell script)에서 사용할 때는 $를 붙여서 사용 합니다.

~]# vi date.sh
echo $(date +'%Y-%m-%d')

~]# chmod +x date.sh

~]# ./date.sh
2021-03-04

* chmod 는 권한을 설정하는 명령어 입니다.

+x (excute) 실행 권한

Posted by 비니미니파파
Server(Windows&Linux)2021. 3. 4. 10:48

리눅스에서는 rdate 라는 명령어로 시간을 동기화 합니다.

 rdate - get the time via the network

~]# rdate -s time.kriss.re.kr

한국표준과학연구원(KRISS) 에서 운영하는 time server 인데 잘 안되네요.

~]# rdate -s time.bora.net

보라넷 시절부터 운영하는 (현재 LG U+) time server 인데 잘 됩니다.

보통은 시간 동기화시 하드웨어(cmos) 까지 세팅을 해야 하기 때문에

 hwclock - query or set the hardware clock (RTC)

명령어를 조합해서 사용합니다.

결론은 아래 와 같이 사용하면 시간동기화 cmos 설정 까지 같이 됩니다.

~]# time -s time.bora.net | hwclock -w
Posted by 비니미니파파
Database/PostgreSQL2020. 11. 6. 16:39

 mdate (속성 timestamp) 컬럼을 '2020-11-01' 에서 '2020-11-06' 일 까지 검색

# 잘못 됨
WHERE to_char(mdate,'YYYY-MM-DD') BETWEEN '2020-11-01' AND '2020-11-06'

# 권장하지 않음
WHERE mdate::date BETWEEN '2020-11-01'::date AND '2020-11-06'::date

데이터가 많은 테이블에서 timestamp 를 to_char 로 변한하면 안 됨.  Index 안 탐.

개선

# mdate 컬럼 속성을 변경하지 않아야 함
WHERE mdate >= '2020-11-01'::timestamp AND mdate < '2020-11-06'::timestamp + interval '1 day'

--> 앞으로 고민 해 봐야 할것

between 을 사용하고 싶은데... + interval '+1day -1second' 이렇게 해도 되긴되는데 

Posted by 비니미니파파
	"columns" : [
	    	{"data" : "no","defaultContent":""},				
	    	{"data" : "name","defaultContent":""},
	    	{"data" : "user_id","defaultcontent":""},				
	    	{"data" : "",
	    		render: function(data,type,row){
	    			return "<button id='btn_info' type='button' class='btn' onClick='openInfo("+row.user_id+")'>상세정보</button>";
	    		}
	    	}
	],

 

function openInfo(user_id) {

	// Table 에서 받은 user_id 출력
	console.log(user_id);
    
}
Posted by 비니미니파파
JavaScript&Platform/jQuery2020. 9. 10. 10:47

<select id="choice">
   <option value="1">하나</option>
   <option value="2">둘</option>
   <option value="3">셋</option>
</select>

<script>

    $("#choice").val("2").prop("selected",true);

</script>

 

* jquery 환경에서 실행 됩니다.

+ 추가 +

change 이벤트가 발생하지 않을 때

    $("#choice").val("1").prop("selected",true).change();

 

Posted by 비니미니파파
Framework2020. 6. 11. 14:24

Thymeleaf 를 이요한 layout 적용 하기

내용이 들어갈 파일

- contents.html

레이아웃 파일

- layout.html

 

1. pom.xml 에 dependency 추가

		<dependency>
			<groupId>nz.net.ultraq.thymeleaf</groupId>
			<artifactId>thymeleaf-layout-dialect</artifactId>
		</dependency>	

 

2. layout.html

<!DOCTYPE html>
<html lang="ko" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
	<meta charset="UTF-8">
	<title>Thymeleaf Layout Test</title>
</head>
<body>
	<div id="header"> 헤더가 들어갈 영역 </div>
    <div id="contents"> 
    	
        <!-- Thymeleaf Content 가 들어갈 영역 -->
        <th:block layout:fragment="content"></th:block>
    
    </div>
</body>
</html>

 

3. contensts.html

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="ko"
	  xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
  	  layout:decorator="layout">
<head>
	<meta charset="UTF-8">
</head>  	  
  	  
<body>
	<th:block layout:fragment="content">
    
    	본문(콘텐츠) 영역
        
    </th>    
</body>
</html>

 

4. 테스트

contents.html 을 호출 하면 layout.html 이 적용되어 화면에 표시된다.

Posted by 비니미니파파
Framework2020. 6. 11. 10:49

Thymeleaf 에서 Session 을 처리 하는 방법

HTML 에서 처리


<span  th:text="${session.user_id}"> USER_ID </span>

Javascript 에서 처리


<script>

let user_id = "[[${session.user_id}]]";

</script>

 

Session 을 처리 하는 방법

HTML 에서 처리

<span  th:text="${param.user_name}"> USER_NAME </span>

Javascript 에서 처리

<script>

let user_name = "[[${param.user_name}]]";

</script>

 

* 간단하지만 자꾸 까먹는다... 

Posted by 비니미니파파
Database/Oracle2020. 6. 4. 09:06

12 버전 이상에서는 rownum 으로 처리 할 필요가 없다.

OFFSET 시작번호 ROWS FETCH NEXT 페이지보여줄갯수 ROWS ONLY

OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY

 


select 
    user_id
   , user_name
from tbl_user
order by user_id
OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY

 

Posted by 비니미니파파
Database/PostgreSQL2020. 6. 3. 18:04

* 주의!!! 성능문제가 발생 한다고 하네요. 이런 방법도 있구나 하고 읽어 주세요 ^^

OFFSET 시작번호 limit 페이지보여줄갯수

OFFSET 0 limit 20;


select 
    user_id
   , user_name
from tbl_user
order by user_id
OFFSET 0 limit 20;

 

ORACLE 문법 도 된다.

 

OFFSET 시작번호 ROWS FETCH NEXT 페이지보여줄갯수 ROWS ONLY

 

OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY

 


select 
    user_id
   , user_name
from tbl_user
order by user_id
OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY

 

되는구나! 

Posted by 비니미니파파
Framework2020. 4. 10. 17:59

eclipse Maven 환경

pom.xml 을 열고 

 dependencies 탭에서 Add

spring-boot-devtools 를 찾아서 추가.

xml 에 잘 추가되어 있다.

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
		</dependency>

src/main/resources 

application.properties 를 열고

spring.devtools.livereload.enabled=true

추가 설정 하면

끝!

 

Posted by 비니미니파파
Database/Oracle2020. 4. 10. 16:20

테이블 명 (table name) 이나 컬럼명(column name) 이 맞는지 확인!

거의 오타 때문이다! 

ㅠㅠ

끝.

Posted by 비니미니파파
Framework2020. 4. 10. 11:46

[Spring + Mybatis] 연동 시 나타나는 java.sql.SQLException: 부적합한 열 유형: 1111

Error setting null for parameter #8 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 부적합한 열 유형: 1111

#{NAME} 을

#{NAME, jdbcType=VARCHAR} 로 수정 하면 된다.

jdbcType 은 컬럼 Type 을 맞춰주자!

끝!

Posted by 비니미니파파
Framework2020. 4. 6. 18:06

Spring boot 에서 tomcat Port 변경 하기

/src/main/resources

application.properties 파일에다 

server.port = 8085

설정 하면 끝...

application.properties 파일 설정을 더 알고 싶다면.

https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html

Posted by 비니미니파파
Server(Windows&Linux)2020. 3. 24. 18:00

Tomcat 로그인 catalina.out 파일 용량이 무한으로 늘어 난다.

특히, log4j 를 사용하여 query 로그를 남기거나 system.out.println 을 남발하면 GB 용량의 catalina.out 을 곧 만나게 된다.

logrotate 를 이용하여 /etc/logrotate.d/tomcat 파일을 만들고 정상적인 테스트 후 하루 지나면 anacron 에서

permission deny 가 났다고 mail 이 와 있을 것이다.

그냥 cronolog 를 사용하자! Tomcat 8.5 기준이다.

 

1. cronolog 설치

~]# yum install cronolog

epel-release 가 설치 되어 있지 않았다면 먼저 설치 후 cronolog를 설치 하자.

~]# yum install epel-release

설치가 잘 되면 /usr/sbin/cronolog 실행 파일이 보일 것 이다.

 

 

2. tomcat catalina.sh 파일 수정 하기


~]# vi catalina.sh
  -- 중략 --
  touch "$CATALINA_OUT"  
  -- 중략 --
      org.apache.catalina.startup.Bootstrap "$@" start \
      >> "$CATALINA_OUT" 2>&1 "&"
  -- 중략 --
      org.apache.catalina.startup.Bootstrap "$@" start \
      >> "$CATALINA_OUT" 2>&1 "&"
      
      

위의 부분을 아래와 같이 바꾼다.


~]# vi catalina.sh
  -- 중략 --
  #touch "$CATALINA_OUT"  
  -- 중략 --
      org.apache.catalina.startup.Bootstrap "$@" start \
      | /usr/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &
  -- 중략 --
      org.apache.catalina.startup.Bootstrap "$@" start \
      | /usr/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &
      
      

 

 

3. tomcat Restart

~]# systemctl restart tomcat

tomcat 의 ~/logs/ 에 catalina.2020-03-24.out 파일이 보인다.

 

 

 

끝~.

Posted by 비니미니파파