database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 7301 게시물 읽기
No. 7301
postGIS 관련 질문요~ㅜ.ㅜ
작성자
기초인
작성일
2008-01-09 10:27
조회수
6,692

import java.sql.*; 

import java.util.*;

import java.lang.*;

import org.postgis.*;

 

public class JavaGIS {

public static void main(String[] args)

{

java.sql.Connection conn;

try

{

/*

* Load the JDBC driver and establish a connection.

*/

Class.forName("org.postgresql.Driver");

String url = "jdbc:postgresql://localhost:5432/database";

conn = DriverManager.getConnection(url, "postgres", "");

 

/*

* Add the geometry types to the connection. Note that you

* must cast the connection to the pgsql-specific connection * implementation before calling the addDataType() method.

*/

((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");

((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");

 

/*

* Create a statement and execute a select query.

*/

Statement s = conn.createStatement();

ResultSet r = s.executeQuery("select AsText(geom) as geom,id from geomtable");

while( r.next() )

{

/*

* Retrieve the geometry as an object then cast it to the geometry type.

* Print things out.

*/

PGgeometry geom = (PGgeometry)r.getObject(1);

int id = r.getInt(2);

System.out.println("Row " + id + ":");

System.out.println(geom.toString());

}

s.close();

conn.close();

}

catch( Exception e )

{

e.printStackTrace();

}

}

}
위에서 보는 것과 같이       ((org.postgresql.Connection) 이부분에서 에러가 ...ㅜㅜ
이 프로그램을 돌리려면 Connection 클래스가 있어야 한다는데요...이걸 어디서 구하나요? 정확한 주소좀 알려주세요~아니면 다른 해결방안이라도..ㅜ.ㅜ




이 글에 대한 댓글이 총 1건 있습니다.
http://jdbc.postgresql.org/
김상기(ioseph)님이 2008-01-09 13:24에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
7304RANK 쿼리문을 만들어 봤습니다. [1]
tyro
2008-01-11
6314
7303view 에서 rule적용 질문 (update, insert, delete) [8]
전홍준
2008-01-11
6624
7302postgresql 초기 설치 방법 [1]
권태영
2008-01-09
10518
7301postGIS 관련 질문요~ㅜ.ㅜ [1]
기초인
2008-01-09
6692
7297md5설정에 관해서 [2]
영광
2008-01-04
6180
7296Procedure sample
.net
2008-01-02
6316
7293디비 튜닝에 대해 조언 구합니다~ [3]
영광
2007-12-26
6753
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.017초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다