try - with - resources문 자바7 버전에서 추가됨. 입출력 처리시 예외가 발생하는 경우 JVM이 자동으로 close()를 호출하여 자원을 반납시켜준다. try - catch문을 이용한 예외 처리 public List getRoles(){ List list = new ArrayList(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { Class.forName("org.mariadb.jdbc.Driver"); conn = DriverManager.getConnection(dburl, dbUser, dbPasswd); String sql = "SELECT description, role_id FR..
JDBC(Java Database Connectivity) 자바 프로그램 내에서 SQL문을 실행하기 위한 자바 API pom.xml에 JDBC 의존성 추가 org.mariadb.jdbc mariadb-java-client 2.7.0 JDBC 사용 설명 package kr.or.connect.jdbcexam.dao; // 1. import java.sql.* import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.L..
Maven 자바용 프로젝트 관리 도구. 이 외에 Ant, Gradle이 있음. 설정 파일에서 의존성 라이브러리를 관리함으로써 직접 다운로드하지 않아도 라이브러리를 사용할 수 있다. 이클립스에 내장된 Maven을 이용해 프로젝트를 생성할 수 있다. 파일구조 project home ㄴsrc ㄴmain ㄴjava : 자바 패키지 폴더와 소스 코드가 위치함. ㄴresources : *.properties, *.xml 등 설정파일들이 위치함. ㄴwebapp : WEB-INF와 웹 관련 리소스(html, jsp)들이 위치함. ㄴtest ㄴjava : 테스트와 관련된 자바 패키지와 소스코드가 위치함. ㄴresources : 테스트와 관련된 설정파일이 위치함. ㄴtarget : 컴파일, 패키징된 결과물이 위치함. ㄴp..
DB 접속 mariadb –h호스트명 –uDB계정명 –p 데이터베이스이름 ex) mariadb -h 127.0.0.1 -u connectuser -p connectdb root 계정은 설치시 입력한 비밀번호 Database 생성 create database DB이름; 권한 부여 grant all privileges on db이름.* to 계정이름@'%' identified by '암호'; flush privileges; db이름 뒤의 * 는 모든 권한을 의미. @'%'는 어떤 클라이언트에서든 접근 가능하다는 의미이고, @'localhost'는 해당 컴퓨터에서만 접근 가능하다는 의미. flush privileges는 DBMS에게 적용을 하라는 의미. db 종료 exit or quit 현재 버전과 날짜 구하..
D드라이브로 이동하기 d:파일 목록 보기 dir
redirect 서버는 클라이언트의 요청에 대해 특정 URL로 이동을 요청하는 것. 웹브라우저 -> 서버 -> 302코드, location값 -> 웹브라우저 -> location값으로 재요청 -> 웹브라우저 브라우저의 주소창은 새 URL로 바뀐다. 예) 게시글 작성 버튼 클릭시 서버에 글 작성 요청 후 글 목록으로 이동하는 경우 소스코드 redirect01.jsp redirect02.jsp redirect된 페이지 입니다. 결과 forward 웹브라우저에서 Servlet1에게 요청 Servlet1은 요청을 처리한 후, 그 결과를 HttpServletRequest에 저장 Servlet1은 결과가 저장된 HttpServletRequest와 응답을 위한 HttpServletResponse를 같은 웹 어플리케이..
JSP JSP는 JSP 자체가 동작하는 것이 아니라 모든 JSP는 서블릿으로 바뀌어서 동작한다. WAS가 지시문의 명령을 받는다. 문법 // 지시문 // import // 선언문; 전역변수 선언 및 메소드 선언에 사용 // scriptlet; 자바코드를 입력할 수 있는 부분 Servlet(Java 파일) Servlet 코드를 컴파일해서 실행가능한 bytecode로 변환한다. -Servlet(Java 파일) -> class class를 로딩하고 인스턴스를 생성한다. servlet이 실행되어 요청을 처리하고 응답 정보를 생성한다. java, class 파일 생성 경로 workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\loc..
폰트 추가 경로 C:\Windows\Fonts TTF(TrueType Font)와 TTC(TrueType Collection) 확장자 1989년 애플사에서 어도비사의 포스트스크립트폰트에 대항하여 개인이 쓸수 있도록 만든 글꼴 저장 형식. 여러개 TTF를 그룹으로 묶은것은 TTC이다. 인쇄할 때 나오는 글꼴과 화면상의 글꼴이 동일하다. 참조 https://m.blog.naver.com/PostView.nhn?blogId=kjwkkht1125&logNo=220702536333&proxyReferer=https:%2F%2Fwww.google.com%2F https://namu.wiki/w/TTF
콜백(call back) 함수 코드를 통해 명시적으로 호출하는 함수가 아니라, 개발자가 단지 함수를 등록하기만 하고, 어떤 이벤트가 발생했거나 특정 시점에 도달했을때 시스템에서 호출되는 함수를 말한다. 보통은 즉시 실행되지 않고, 나중에 필요한 시점에 실행되거나, 실행이 안 될 수도 있다. 콜백(call back) 함수의 예 익명 함수 함수의 인자로 넘겨서, 코드 내부에서 호출되는 함수 소스코드 var xhr = new XMLHttpRequest(); xhr.onload = function () { //load 될 때, callback 함수가 실행된다. if (xhr.status == "200") { console.log("success"); } } xhr.open("GET", "type?id=" + e..