main
[Spring legacy] Oracle DB 연결하기 (ojdbc11/jdk11) 본문
1. SQL Developer 설치 폴더 > jdbc > lib 폴더에 jdk 11 버전용 ojbc11.jar 파일이 존재한다.
2. 프로젝트 우클릭 > Build Path > Configure Build Path...
3. Libraries 탭 > Classpath 클릭 > Add External JARs... 클릭
3. ojdbc11.jar 선택 > Apply
4. Apply
5. 프로젝트 우클릭 > Properties > Deployment Assembly
6. Java Build Path Entries 클릭
7. ojdbc11.jar 선택 > Finish
8. Apply and Close
9. Oracle 접속 테스트 코드
package com.example.persistence;
import static org.junit.Assert.fail;
import java.sql.Connection;
import java.sql.DriverManager;
import org.junit.Test;
import lombok.extern.log4j.Log4j;
@Log4j
public class JDBCTest {
static {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void TestConnection() {
try (Connection conn =
DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe",
"$ID",
"$PASSWORD")) {
log.info(conn);
} catch (Exception e) {
fail(e.getMessage());
}
}
}
10. 끝
728x90
'Java > Spring' 카테고리의 다른 글
[Spring] commons-fileupload 기본 설정 및 테스트 (0) | 2023.04.23 |
---|---|
[Spring legacy] Mybatis 연결하기 (0) | 2023.04.22 |
[Spring legacy] 프로젝트 초기 설정 (STS3/Java11/tomcat 9.0) (0) | 2023.04.22 |
[STS] spring legacy project 없는 경우 (0) | 2023.04.22 |
[Spring] Tomcat 10.1 다운로드 및 설정 (Java 11/Windows/Eclipse/STS) (0) | 2023.04.22 |
Comments