测试代码:
package com.bjq01.cleaner;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
public class PhonixJDBC {
public static void main(String[] args) throws SQLException {
try {
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
Connection conn = DriverManager.getConnection("jdbc:phoenix:172.16.169.162");
Statement statement = conn.createStatement();
System.out.println(new Date());
ResultSet ret = statement.executeQuery("select count(distinct(state)) cnt from US_POPULATION group by state");
int rowCount = 0;
while(ret.next()){
rowCount=ret.getInt("cnt");
System.out.println(rowCount);
}
System.out.println(new Date());
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
}
}