목차

Jdbc

  • description : 자바 프로그래밍 관련 내용
  • author : 주레피
  • email : dhan@repia.com
  • lastupdate : 2020-03-09

Oracle

오라클 연동

import java.sql.DriverManager;
import java.sql.SQLException;
 
public class OracleEx01 {
 
	public static void main(String[] args) {
		String driver = "oracle.jdbc.driver.OracleDriver";
		String url = "jdbc:oracle:thin:@localhost:1521:xe";
		String user = "scott";
		String password = "tiger";
		try {
			Class.forName(driver);
			System.out.println("jdbc driver 로딩 성공");
			DriverManager.getConnection(url, user, password);
			System.out.println("오라클 연결 성공");
		} catch (ClassNotFoundException e) {
			System.out.println("jdbc driver 로딩 실패");
		} catch (SQLException e) {
			System.out.println("오라클 연결 실패");
		}
	}
}

Ref