该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
首先,需要去greenplum的官方网站下载最新的JDBC驱动包,
地址:http://jdbc.postgresql.org/download.html
我的下是这个postgresql-9.2-1003.jdbc4.jar
然后在Eclipse中引入这个驱动包,新建一个测试类,如下:
import java.sql.*;
public class GreenPlumDataBaseLink {
public static void main(String[] args) {
String usr = "用户名";
String pwd = "密码";
String url = "jdbc:postgresql://服务器IP地址:5432/你的数据库名称";
try{
Class.forName("org.postgresql.Driver");
System.out.println("Success loading Driver!");
}catch(Exception e){
System.out.println("Fail loading Driver!");
e.printStackTrace();
}
try{
Connection db = DriverManager.getConnection(url, usr, pwd);
System.out.println("Success connecting server!");
}catch(Exception e){
System.out.println("Connection URL or username or password errors!");
e.printStackTrace();
}
}
}