Bon Long Ray - Documents for our current project.

Eclipse 连接 PostgreSQL

1. 安装 PostgreSQL 的 JDBC 驱动

可以直接安装源里的 libpg-java.8.1-404.1,也可以从 PostgreSQL 的 JDBC 驱动下载页获取最新的 407 版本。

安装的标准路径与早期版本不同,为 /usr/share/java 。

关于驱动文件的选择 (摘自PostgreSQL 驱动下载页):


JDBC Version Selection

To determine which JDBC version of the driver you want you need to look at the JDK version you are running.

  • JDK 1.1 - JDBC 1. Note that with the 8.0 release JDBC 1 support has been removed, so look to update your JDK when you update your server.
  • JDK 1.2, 1.3 - JDBC 2.
  • JDK 1.3 + J2EE - JDBC 2 EE. This contains additional support for javax.sql classes.
  • JDK 1.4, 1.5 - JDBC 3. This contains support for SSL and javax.sql, but does not require J2EE as it has been added to the J2SE release.

2. Connection 设置

以 Database Explorer 为例,首先添加 DE 的视图,Window-> Show View -> Other -> Data -> Database Explorer。

在打开的 DE 视图中,New Connection:


关键在于
  1. JDBC driver class 的名称;
  2. 所选择的驱动包;
  3. Connection URL 的格式。
______
(完)

没有评论: