HbaseUtil.java
HbaseUtil.java是一个用于操作HBase的工具类,通过封装常见的HBase操作,提高了对HBase数据库的使用效率。该类提供了创建连接、增删改查等常见功能。下面是HbaseUtil.java的代码示例:
public class HbaseUtil {
public static Connection getConnection() throws IOException {
Configuration config = HBaseConfiguration.create();
return ConnectionFactory.createConnection(config);
}
public static void putData(Table table, Put put) throws IOException {
table.put(put);
}
public static Result getData(Table table, Get get) throws IOException {
return table.get(get);
}
public static void closeConnection(Connection connection) throws IOException {
if (connection != null) {
connection.close();
}
}
}
暂无评论