Esta página aún no está disponible en su idioma local. Estamos trabajando arduamente para agregar más versiones de idiomas. Gracias por tu apoyo.

On this page

Writing Data to the PhoenixTable

Updated on 2022-09-14 GMT+08:00

Function

The Phoenix table enables data writing in HBase.

Example Code

The following code snippet belongs to the testPutmethod in the PhoenixSample class of the com.huawei.bigdata.hbase.examplespackage.

  /**
   * Put data
   */
  public void testPut() {
    LOG.info("Entering testPut.");
    String URL = "jdbc:phoenix:" + conf.get("hbase.zookeeper.quorum");
    // Insert
    String upsertSQL =
        "UPSERT INTO TEST VALUES(1,'John','100000', TO_DATE('1980-01-01','yyyy-MM-dd'))";
    try (Connection conn = DriverManager.getConnection(url, props);
        Statement stat = conn.createStatement()){
      // Execute Update SQL
      stat.executeUpdate(upsertSQL);
      conn.commit();
      LOG.info("Put successfully.");
    } catch (Exception e) {
      LOG.error("Put failed.", e);
    }
    LOG.info("Exiting testPut.");
  }
Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback