티스토리 뷰
출처 : http://www.lug.or.kr/docs/LINUX/KLDP/KoreanDoc/html/JServ_PgSQL-KLDP-html/JServ_PgSQL-KLDP-5.html
1. JDBC 드라이버 받기
http://jdbc.postgresql.org/download.html
2. JDBC Connection 접속 소스
/**
* JDBC Connection String Examples
*
* jdbc:postgresql:database_name
* jdbc:postgresql://host/database_name
* jdbc:postgresql://host:port/database_name
*/
import java.sql.*;
public class PgsqlJdbcTest {
public static void main(String[] args) throws Exception {
String url = "jdbc:postgresql:db_study";
String usr = "scott";
String pwd = "tiger";
Class.forName("org.postgresql.Driver");
// -- 1
Connection conn = DriverManager.getConnection(url, usr, pwd);
System.out.println(conn);
conn.close();
// -- 2
url = "jdbc:postgresql://localhost/db_study";
conn = DriverManager.getConnection(url, usr, pwd);
System.out.println(conn);
conn.close();
// -- 3
url = "jdbc:postgresql://localhost:5432/db_study";
conn = DriverManager.getConnection(url, usr, pwd);
System.out.println(conn);
conn.close();
}
}
3. 실행 결과
C:\>java -cp .;postgresql-8.4-701.jdbc4.zip PgsqlJdbcTest
org.postgresql.jdbc4.Jdbc4Connection@89fbe3
org.postgresql.jdbc4.Jdbc4Connection@f81843
org.postgresql.jdbc4.Jdbc4Connection@dd5b
- Total
- Today
- Yesterday
- ffmpeg
- 서울오토살롱
- android
- MySQL
- Linux
- ubuntu
- Xcode
- SAS
- KOBA
- Spring
- koba2010
- BPI-M4
- Mac
- flex
- 튜닝쇼 2008
- 지스타2007
- Java
- 송주경
- Delphi Tip
- 레이싱모델 익스트림 포토 페스티벌
- 동경
- 일본여행
- Delphi
- oracle
- sas2009
- ble
- JavaScript
- NDK
- 전예희
- Spring MVC
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |