Help Center/
    
      
      MapReduce Service/
      
      
        
        
        Developer Guide (LTS)/
        
        
        HBase Development Guide (Security Mode)/
        
        
        Developing the HBase Application/
        
        
        HBase Data Read/Write Sample Program/
        
      
      Inserting Data into the Phoenix Table
    
  
  
    
        Updated on 2025-04-14 GMT+08:00
        
          
          
        
      
      
      
      
      
      
      
      
  
      
      
      
        
Inserting Data into the Phoenix Table
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.examples package.
  /**
   * 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.");
  }
 
   Parent topic: HBase Data Read/Write Sample Program
  
 Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
                The system is busy. Please try again later.
                
            
        For any further questions, feel free to contact us through the chatbot.
Chatbot