Java

[Java] PostgreSQL-JDBC 연결하는 방법 (Eclipse 기준)

15호의 개발자 2021. 12. 27. 10:44
반응형

[Java] PostgreSQL-JDBC 연결하는 방법 (Eclipse 기준)

 

 

  • PostgreSQL 설치

아래 링크에서 자신의 OS에 맞는 PostgreSQL을 다운로드 받는다. pgAdmin을 사용하기 위함이다.

 

PostgreSQL: Downloads

Downloads PostgreSQL Downloads PostgreSQL is available for download as ready-to-use packages or installers for various platforms, as well as a source code archive if you want to build it yourself. Packages and Installers Select your operating system family

www.postgresql.org

 

 

 

  • PostgreSQL JDBC 드라이버 설치

아래 링크에서 PostgreSQL JDBC Driver를 다운로드 받을 수 있다.

 

PostgreSQL JDBC Download

Download About Binary JAR file downloads of the JDBC driver are available here and the current version with Maven Repository. Because Java is platform neutral, it is a simple process of just downloading the appropriate JAR file and dropping it into your cl

jdbc.postgresql.org

최신 버전을 사용하고 싶다면 위의 형광펜 칠한 부분을 선택하면 된다.

다른 버전을 사용하고 싶다면 위 링크 아래쪽에 잘 나와있으니 취향껏 다운로드를 받는다.

 

 

 

  • Path에 추가

(Eclipse IDE 기준)

 

Project Explorer상에서 작업하고 있는 project 우클릭 > Properties > Java Build Path (찾기 어려울 시 "type filter text"란에 입력한다) > Libraries 탭 > Modulepath에서 Add Library 클릭 > User Libary > User Libraries > New > 라이브러리 네임 입력 (ex. PostgreSQL JDBC) > Add External JARs > 다운받은 JDBC 드라이버(jar 파일) 선택 > Apply and Close > Apply and Close

 

 

 

  • JDBC 연결 코드 작성

JDBC 연결 코드를 작성한 후 커넥션이 잘 되었는지 확인하면 마무리 된다.

 

반응형