hbase總結:插入資料的表名不存在或和建立的表名不一致
阿新 • • 發佈:2019-02-16
異常情況一:
public static void main(String[] args) { try { QueryRunner qr = MyDbutils.getQueryRunner(); String sql = "SELECT * FROM OptionInfo"; List<OptionInfo> list = qr.query(sql, new BeanListHandler(OptionInfo.class)); HBaseManager.creatTable("MetaData_test", "Info"); new InsertHbase().insertIntoHbase("MetaData_Test",list); } catch (Exception e) { e.printStackTrace(); } }
仔細檢視這兩句:
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">HBaseManager.creatTable(tableName, "Info");</span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">new InsertHbase().insertIntoHbase(tableName,list);</span>
程式會出現如下錯誤:
org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException: Failed 1 action: MetaData_Test: 1 time,
at org.apache.hadoop.hbase.client.AsyncProcess$BatchErrors.makeException(AsyncProcess.java:203)at org.apache.hadoop.hbase.client.AsyncProcess$BatchErrors.access$500(AsyncProcess.java:187)
at org.apache.hadoop.hbase.client.AsyncProcess.getErrors(AsyncProcess.java:922)
at org.apache.hadoop.hbase.client.HTable.backgroundFlushCommits(HTable.java:991)
at org.apache.hadoop.hbase.client.HTable.flushCommits(HTable.java:1287)
at org.apache.hadoop.hbase.client.HTable.put(HTable.java:917)
at com.dh.metaData.InsertHbase.insertIntoHbase(InsertHbase.java:37)
at com.dh.metaData.MetaData.main(MetaData.java:22)
解決方案:保證建立表名和插入表的表名一致!!!推薦使用同一個變數!
String tableName="MetaData_test";
HBaseManager.creatTable(tableName, "Info");
new InsertHbase().insertIntoHbase(tableName,list);