삭제는 삭제프로그램을 사용해서 지워야한다..

오라클은 설치는 쉬워도 삭제가 까탈스럽다.

 

자바 설치되어있는 경로로 찾아가서 라이브러리에 넣어줬었다.

 

 

여기다가 ojdbc6 복사해서 해당 경로에 넣어주기

 

 

javascript

var 자료형은 타입추론 

 

java

람다식 함수 표현

참고링크 클릭!

 

[JAVA] 람다식(Lambda)의 개념 및 사용법

람다함수란? 람다 함수는 프로그래밍 언어에서 사용되는 개념으로 익명 함수(Anonymous functions)를 지칭하는 용어입니다. 현재 사용되고 있는 람다의 근간은 수학과 기초 컴퓨터과학 분야에서의 람

khj93.tistory.com

 

함수형 프로그래밍

객체지향형 프로그래밍

 

ojdbc6 디펜던시 추가

repositories 추가

   <repositories>
      <repository>
         <id>oracle</id>
         <name>ORACLE JDBC Repository</name>
         <url>https://maven.atlassian.com/3rdparty/</url>
      </repository>
   </repositories>

 

 

JUnit Test Case

 

try ( ) 문 안에 넣어주면 알아서 빌리고 반납한다.

 

 

Test쪽 에러 처리 -> 첫번째 add JUnit 4 라이브러리 추가 클릭

 

thin : 3계층

 

 

package com.smart.hrd;

import java.sql.Connection;
import java.sql.DriverManager;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class OracleConnectionTest {

	private static final Logger log = LoggerFactory.getLogger(OracleConnectionTest.class);
	private static final String DRIVER = "oracle.jdbc.driver.OracleDriver";
	private static final String URL = "jdbc:oracle:thin:@59.0.234.4:1521:xe";
	private static final String USER = "hr";
	private static final String PW = "hr";

	static {
		try {
			Class.forName(DRIVER);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Test
	public void test() {
		// jdk1.7부터 사용 가능
		// try ~ with구문을 활용 → finally부분이 없이 자동으로 close()가 호출
		// try안의 ()에 선언되는 객체가 AutoClosable이라는 인터페이스를 구현 한 객체
		try (Connection con = DriverManager.getConnection(URL, USER, PW)) {

			log.info("" + con);
			System.out.println(con);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

 

 

 

 

Run As -> JUnit Test 실행 -> 뒤에 다 오케이 클릭

 

 

이렇게 나오면 성공

 

 

 

HikariCP 

 

 

3.4.1 ㄱㄱ

복사

 

붙여넣기

 

추가 된거 확인

 

 

 

root-context.xml 열기

 

 

bean 주석 밑에 추가

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
	
	<!-- Root Context: defines shared resources visible to all other web components -->
	<!-- HikariCP Oracle 설정 -->
   <bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
         <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
         <property name="jdbcUrl" value="jdbc:oracle:thin:@192.168.0.102:1521:XE"></property>
         <property name="username" value="scott"></property>
         <property name="password" value="tiger"></property>
   </bean>
   
   <bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"></bean>
</beans>

 

 

객체를 관리할 주소 입력해주기

하단 콘솔 위 Namespaces 클릭

 

 

con

context 체크후 오케이

 

Beans Graph 클릭

 

 

Beans Graph가 안뜰때 

root-context 오른쪽 클릭 -> Spring -> Remove as Bean Configuration

 

 

 

객체 주소 추가

<context:component-scan base-package="com.smart.hrd"></context:component-scan>

 

 

 

pom.xml 열어서

junit 4.7 ->4.12 로 변경

 

 

<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-test</artifactId>
	<version>${org.springframework-version}</version>
	<scope>test</scope>
</dependency>

디펜던시 추가

 

 

 

JUnit 파일 하나더 추가

 

 

@RunWith(SpringJUnit4ClassRunner.class)

추가

 

 

 

작성

package com.smart.hrd;

import static org.junit.Assert.*;

import java.sql.Connection;

import javax.sql.DataSource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import lombok.Setter;
import lombok.extern.log4j.Log4j;
// 지정한 클래스를 이용해 테스트 메서드를 수행하도록 지정해주는 어노테이션
@RunWith(SpringJUnit4ClassRunner.class)
// 지정된 클래스나 문자열을 이용해서 필요한 객체들을 스프링 내에 객체로 등록
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/root-context.xml")
// 롬복을 이용해서 로그를 기록하는 Logger 변수를 생성
@Log4j
public class DataSourceTest {
	
	// @Setter : 롬복 라이브러리를 이용해 setter를 자동으로 만들어 주는 어노테이션
	// @Autowired : *인스턴스 변수 에 알맞은 타입의 객체를 자동으로 주입해주는 어노테이션
	// *인스턴스 변수 = dataSource
	@Setter(onMethod_ = { @Autowired })
	private DataSource dataSource;

	@Test
	public void testConnection() {
		try (Connection con = dataSource.getConnection()) {
			log.info(con);
		} catch (Exception e) {
			fail("Not yet implemented");
		}
	}

}

 

 

 

 

 

 

 

 

 

 

 

 

 

+ Recent posts