ImpalaJdbc
首先要引入ImpalaJDBC41.jar包。可以网上找,也可以直接下面的地址下载。
链接:https://pan.baidu.com/s/1MTJ0Wn1pwEmtXwp-_E4gIw
提取码:j00u
public static void main(String[] args) throws ClassNotFoundException, SQLException { //这个地址填写自己的impala server地址,默认端口为21050
//默认连接default库,这里是wx,使用AuthMech=0不验证用户密码
String connectionUrl = "jdbc:impala://10.xx.xx.xxx:21050/wx;AuthMech=0";
String jdbcDriverName = "com.cloudera.impala.jdbc41.Driver";
//简单的一个查询语句
String sql = "SELECT F_GNMC,COUNT(1) AS count FROM SYS_OPLOG where F_USER=?" +
" GROUP BY F_GNMC order by count desc limit ?";
Connection con = DriverManager.getConnection(connectionUrl);
//加载驱动
Class.forName(jdbcDriverName);
//查询
// Statement stmt = con.createStatement();
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, "10026413");
ps.setInt(2, 10);
Long start = System.currentTimeMillis();
System.out.println("---begin query---" + start);
// ResultSet rs = ps.executeQuery(sql);
ResultSet rs = ps.executeQuery();
Long end = System.currentTimeMillis();
//打印输出
while (rs.next()) {
String gnmc = rs.getString(1);
String count = rs.getString(2);
System.out.println(gnmc + " " + count);
}
System.out.println("---end query---" + end);
System.out.println((end - start) + "ms");
}
保存 6218查询 6104
刷新 4485
提交 4287
流程审批查询 3881
流程 3851
确定 3268
首页 3012
新增 2381
显示查询 1934
---end query---1585193941742
676ms
以上是 ImpalaJdbc 的全部内容, 来源链接: utcz.com/z/532827.html