def toHbase(rows: DataFrame,tableName : String,columnFamily: String) { val configuration = HBaseConfiguration.create(); val admin = new HBaseAdmin(configuration) if (admin.tableExists(tableName)) { print("table Exists") admin.disableTable(tableName); admin.deleteTable(tableName); } configuration.addResource("hbase-site.xml") val tableDesc = new HTableDescriptor(tableName) tableDesc.addFamily(new HColumnDescriptor(columnFamily)) admin.createTable(tableDesc) rows.foreachPartition { row => val table = new HTable(configuration, tableName) row.foreach { a => val put = new Put(Bytes.toBytes("row1")) put.add(Bytes.toBytes(columnFamily), Bytes.toBytes("coulumn1"), Bytes.toBytes(a.getString(0))) table.put(put) println("insert into success") } }