1 / 20

JDBC 소개 및 설치

JDBC 소개 및 설치. Database Laboratory. JDBC. What is the JDBC? JAVA Database Connectivity 의 약어 자바와 데이터베이스 사이를 연결 연결된 데이터베이스의 종류와 상관없이 동일한 방법으로 자바가 데이터베이스 내에서 발생하는 트랜잭션을 제어할 수 있도록 하는 환경을 제공. JDBC Driver Manager. 자바는 JDBC Driver Manager 를 통하여 데이터베이스에 접근 가능

Télécharger la présentation

JDBC 소개 및 설치

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JDBC 소개 및 설치 Database Laboratory

  2. JDBC • What is the JDBC? • JAVA Database Connectivity의 약어 • 자바와 데이터베이스 사이를 연결 • 연결된 데이터베이스의 종류와 상관없이 동일한 방법으로 자바가 데이터베이스 내에서 발생하는 트랜잭션을 제어할 수 있도록 하는 환경을 제공 Database Laboratory

  3. JDBC Driver Manager • 자바는 JDBC Driver Manager를 통하여 데이터베이스에 접근 가능 • 드라이버 매니저는 애플리케이션과 데이터베이스 드라이버 사이에서 프로그래머로 하여금 드라이버를 손쉽게 제어할 수 있게 함 • 다양한 범주의 드라이버를 단일한 드라이버 인터페이스를 통해 제어하여 프로그램 이식성 제공 Database Laboratory

  4. JDBC Driver 종류 • 드라이버 매니저에 의해 제공되는 드라이버는 다음의 네 가지 타입으로 분류 • JDBC-ODBC bridge driver • Native-AIP partly-JAVA driver • JDBC-NET pure JAVA driver • Native-protocol pure JAVA driver 상위 type 하위 type Database Laboratory

  5. JDBC Driver 종류 • 각각의 타입에 따라서 JDBC 드라이버의 구현 방법이 다르며, System independency와 performance 등에 기본적인 차이를 보임 • 일반적으로 상위 타입으로 갈수록 performance와 independency가 증가 Database Laboratory

  6. JDBC Driver Download • JDBC 드라이버 검색 • Microsoft Download • http://www.microsoft.com/ko-kr/download/details.aspx?id=21599 • MSDN • http://msdn.microsoft.com/ko-kr/library/ms378749.aspx Database Laboratory

  7. Microsoft SQL Server JDBC 드라이버 3.0 다운로드 Database Laboratory

  8. JDBC Driver Download • JDBC 드라이버 설치 • Slef-extarct형태의 압축 파일이 다운로드 되며, 이를 실행하여 압축을 해제 Database Laboratory

  9. JDBC Driver 설정 • JDBC 드라이버 설치 • 압축을 해제하고 경로를 확인한다. Database Laboratory

  10. JDBC Driver 설정 • Classpath설정 • [제어판]에서 [시스템]을 통해 [고급 시스템 설정]을 선택한다. • [시스템 속성]창에서 [고급]탭을 선택하고 [환경변수]를 선택한다. Database Laboratory

  11. JDBC Driver 설정 • Classpath설정 • 시스템 변수에 새로 만들기를 클릭하여 MSJDBC라는 변수를 생성한다. • 변수 값은 본인이 설치한 JDBC드라이버 위치에 존재하는 sqljdbc.jar파일을 써주면 된다. • 만일 본인이 jdk 1.6이상의 버전을 사용한다면 sqljdbc4.jar로 설정한다. Database Laboratory

  12. JDBC Driver 설정 • Classpath설정 • Classpath변수를 편집하여 MSJDBC변수를 classpath변수에 등록 Database Laboratory

  13. JDBC Driver Download (2) • i-net software사의 MS-SQL용 JDBC 드라이버 • MERLIA : JDBC 3.0 및 4.0지원 • OPTA : JDBC 2.0 과 추가 기능 지원 • SPRINTA : JDBC 2.0지원 • UNA : JDBC 1.22지원 • https://www.inetsoftware.de Database Laboratory

  14. JDBC Driver Download (2) • i-net software사의 MS-SQL용 JDBC 드라이버 Database Laboratory

  15. JDBC Driver Download (2) • merlia드라이버 설치 Database Laboratory

  16. JDBC Driver 설정 (2) • Classpath설정 • 시스템 변수에서 새로 만들기를 클릭하여 MERLIA라는 변수를 생성한다. • 변수값은 본인이 설치한 JDBC드라이버 위치에 존재하는 Merlia.jar 파일을 적어준다. Database Laboratory

  17. JDBC Driver 설정 (2) • Classpath설정 • Classpath변수를 편집하여 MERLIA변수를 Classpath변수에 등록한다. Database Laboratory

  18. Statement 인터페이스 • 예제 1 : Staetment를 통한 질의 처리 • JDBC를 위한 클래스 • MS-JDBC드라이버를 통해 MS-SQL에 연결하기 위한 접근자 • SQL서버에서 수행할 질의 • SQL서버에 세션연결을 수행할 Connection 인터페이스 • SQL 명령을 수행하고 그 결과값을 저장하기 위해 정의된 Statement 객체 ① 데이터베이스 주소 ② ③ ④ ⑤ 포트번호 DB명 Database Laboratory

  19. Statement 인터페이스 • 예제 1 : Staetment를 통한 질의 처리 • DriverManager를 통한 Connection 성립 • Connection에서는 Session을 성립시킴 • 데이터 처리 과정 • Statement를 통해 질의를 수행하고 ResultSet의 결과를 반환 • ResultSet의 next()메소드를 통해 각 Row의 데이터를 가져오고 getXXX()메소드를 통해 각 Column의 데이터를 지정한 타입으로 가져옮 • next()를 통해 더 이상 참조할 결과가 없다면 false를 반환 • 리소스 확보를 위해 연결 종료 ① ② 계정과 암호 ③ Database Laboratory

  20. Statement 인터페이스 • 예제 1 : Staetment를 통한 질의 처리 • 질의문 • Select OrderID, CustomerID, EmployeeID from orders • 소스파일 • Ex1.java • 실행클래스 • Ex1 Database Laboratory

More Related