oracle jdbc 연동 (intellj)

이진섭·2023년 6월 13일
0

유료버전 기준..

mvnrepository.com

  • oracle jdbc 추가 (gradle)
    implementation group: 'com.oracle.database.jdbc', name: 'ojdbc8', version: '23.2.0.0'

     String url = "jdbc:oracle:thin:@localhost:1521:xe";
           String user = "USER_ID";
           String password = "PASSWORD";
           try {
               //1. JDBC드라이버로딩
               Class.forName("oracle.jdbc.driver.OracleDriver");
               System.out.println("드라이버로딩성공");
               // Connection 객체 추가
                Connection con = DriverManager.getConnection(
                       url,user,password
               );
               System.out.println("연결 성공!!");
               Assertions.assertNotNull(con);//null이 아님을 확신
               con.close();//연결 종료
    
           } catch (ClassNotFoundException e) {
               System.out.println("드라이버로딩실패");
               e.printStackTrace();
           }catch (SQLException e) {
               throw new RuntimeException(e);
           }

드라이버로딩성공!
연결 성공!!
BUILD SUCCESSFUL in 6s

profile
하루하루성장하기

0개의 댓글