1) JDBC Download
https://jdbc.postgresql.org/download.html |
2) 다운 받은 파일을 폴더 생성해서 넣어준다.
3) Jar 폴더 생성
4) eclipse-workspace 폴더안에 프로젝트명에 jar 폴더안에 postgresql-42.3.3.jar 복사
5) import 및 소스
import java.sql.*; |
String svripDatabasename = "jdbc:postgresql://127.0.0.1:5432/postgres"; String userid = "postgres"; String pwd = "shinhan3262"; try (Connection connection = DriverManager.getConnection(svripDatabasename, userid, pwd);) { Statement smt = connection.createStatement(); ResultSet rs = smt.executeQuery("SELECT current_date"); while(rs.next()) { System.out.println(rs.getString(1) ); } rs.close(); smt.close(); connection.close(); } catch (SQLException e) { e.printStackTrace(); } |
'Ubuntu' 카테고리의 다른 글
웹서버 개발 환경 (Apache + PHP + Mysql ) #1 (0) | 2023.05.24 |
---|---|
ubuntu -> opencv 설치 (0) | 2022.07.27 |
"moserial" Ubuntu용 Rs232 통신 프로그램 (0) | 2022.03.25 |
JAVA GUI PROGRAMING (0) | 2022.03.24 |
Ubuntu java eclips개발환경 (0) | 2022.03.24 |