[ot-video type=”youtube” url=”https://youtu.be/0inJzz_OAoQ”]

[button link=”https://goo.gl/1oSha6″ icon=”fa-play” side=”left” target=”_blank” color=”b70900″ textcolor=”ffffff”]유튜브 JDBC 프로그래밍 강좌 [/button]

 

데이터베이스 연결하기

[blockquote style=”1″]
초보자를 위한 잠자리 JDBC 프로그래밍 강좌입니다.
[/blockquote]

오라클 데이터베이스 연결 예제 #2

 

    try{
      // Class DriverManager
      // getConnection(String url, String user, String password)
      con = DriverManager.getConnection(
      "jdbc:oracle:thin:@localhost:1521:orcl",
      "tester1","1234");
    } catch(SQLException se){
      // SQLException 
      // if a database access error occurs or the url is null
      System.out.println("오라클의 로그인에 실패했습니다.");
    }
    System.out.println("오라클의 로그인에 성공했습니다.");
    
    return con;    
  } // End of getConnection()
  
  public static void main(String[] args) {
    Connection commOracle = null;
    try{
      commOracle = OracleConnection.getConnection();
      System.out.println("커넥션 객체 : "+ commOracle);
    }catch(Exception e){
    }finally{
    
    try{
      if (commOracle != null) commOracle.close();
    }catch(Exception e){
      e.printStackTrace();
    }
    }
  } // End of main()

} // End of class OracleConnection

<저작권자 ⓒ잠자리(jamjalee.com) 무단 전재-재배포 금지>

[button link=”https://www.jamjalee.com/?p=1031″ icon=”fa-fast-forward” side=”right” target=”_self” color=”232323″ textcolor=”ffffff”]다음 페이지 [/button]