Java 整合Phoenix + HBase 连接超时问题的解决

前言:

用到HBase的背景也是因为数据量到达了一定的量级,传统的关系型数据库存储处理有些乏力,故转为HBase这种扩展性更强、处理大数据更强的存储方式。

连接示例
   try {
        Connection con =
                DriverManager.getConnection("jdbc:phoenix:hb-proxy-pub1,hb-proxy-pub2,hb-proxy-pub3", props);
        Statement stmt = con.createStatement();
        stmt.execute("drop table if exists test");
        stmt.execute("create table test (mykey integer not null primary key, mycolumn varchar)");
        stmt.execute("create index test_idx on test(mycolumn)");
        stmt.executeUpdate("upsert into test values (1,'World!')");
        stmt.executeUpdate("upsert into test values (2,'Hello')");
        stmt.executeUpdate("upsert into test values (3,'World!')");
        con.commit();
        PreparedStatement statement = con.prepareStatement("select mykey from test where mycolumn='Hello'");
        ResultSet rset = statement.executeQuery();
        while (rset.next()) {
            System.out.println(rset.getInt(1));
        }

        rset.close();
        con.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
连接超时

当检索大量数据的时候,可能会在等待一段时间后报错:

java.util.concurrent.ExecutionException: org.apache.phoenix.exception.PhoenixIOException: Failed after attempts=36, exceptions:

Caused by: org.apache.phoenix.exception.PhoenixIOException: Failed after attempts=36, exceptions:

Caused by: org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions:

Caused by: java.net.SocketTimeoutException
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值