HTable(config,tablename)类型已被弃用。有什么用呢? [英] The type HTable(config,tablename) is deprecated. What use instead?

查看:1667
本文介绍了HTable(config,tablename)类型已被弃用。有什么用呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用什么来代替 HTable(config,tablename)



此方法已弃用。在每个例子中,我都可以找到他们使用这个或另一个构造函数,这也被弃用。

解决方案

手动构建 HTable 已被弃用。请使用 连接 来实例化



通过连接,可以使用 Connection.getTable(TableName)



<例如:

  Connection connection = ConnectionFactory.createConnection(config); 

Table table = connection.getTable(TableName.valueOf(table1));

尝试
{
//根据需要使用表,对于单个操作和单个线程
}
finally
{
table.close();
connection.close();
}


What can I use instead of HTable(config,tablename)?

This method is deprecated. In every example I could find they use this or another Constuctor, which is also deprecated.

解决方案

Constructing HTable objects manually has been deprecated. Please use Connection to instantiate a Table instead.

From a Connection, Table implementations are retrieved with Connection.getTable(TableName)

Example:

Connection connection = ConnectionFactory.createConnection(config);

Table table = connection.getTable(TableName.valueOf("table1"));

try 
{
   // Use the table as needed, for a single operation and a single thread
} 
finally
{
   table.close();
   connection.close();
}

这篇关于HTable(config,tablename)类型已被弃用。有什么用呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆