try {
// URL
String url = "jdbc:pivotal:greenplum://host:port;DatabaseName=<name>";
// 数据库用户名
String username = "gpadmin ";
// 数据库密码
String password = "gpadmin";
// 加载驱动
Class.forName("com.pivotal.jdbc.GreenplumDriver");
// 获取连接
Connection conn = DriverManager.getConnection(url, username, password);
String sql = "select * from testTable";
PreparedStatement pre = conn.prepareStatement(sql);
ResultSet rs = pre.executeQuery();
while(rs.next())
{
System.out.println(rs.getString(1));
}
} catch (Exception e) {
e.printStackTrace();
}
在此附上Greenplum驱动jar包下载地址: http://download.csdn.net/download/enterings/10039723
希望大家少走弯路!