Upsert/Read into/from Cassandra database using Datastax API (using new Binary protocol)

后端 未结 1 342
借酒劲吻你
借酒劲吻你 2021-01-28 12:18

I have started working with Cassandra database. I am planning to use Datastax API to upsert/read into/from Cassandra database. I am totall

相关标签:
1条回答
  • 2021-01-28 12:49

    In your cassandra.yaml file look for the tag start_native_transport, by default its disabled, enable it.

    Playing with Datastax Java Driver is quite similar like jdbc driver.

    Insertion code

     String query = "insert into test(key,col1,col2) values('1','value1','value2')";
     session.execute(query);
    

    Reading from Cassandra

     String query="select * from test;";
     ResultSet result = session.execute(query);
     for (Row rows: result){
         System.out.println(rows.getString("key"));
     } 
    
    0 讨论(0)
提交回复
热议问题