Notice
Recent Posts
Recent Comments
Link
07-26 04:14
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

study-project

JDBC 연결확인을 위한 테스트 코드 본문

TIL/Spring

JDBC 연결확인을 위한 테스트 코드

귤식빵 2021. 2. 17. 19:20
package org.zerock.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 JDBCTests {
	
	static {
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void testConnection() {
		try(Connection  con =
				DriverManager.getConnection("URL", "아이디", "비밀번호")) {
			log.info(con);
		} catch (Exception e) {
			fail(e.getMessage());
		}

	}


	}
	


 

정상적으로 연결 되었다면 log.info(con) 가 콘솔에 객체를 출력해줄 것이다.

Comments