share

Monday, 8 June 2015

Insert Data Into Cassandra Example Set 2

import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Session;

public class CassandraExample {
   
    public static void main(String[] args) {
       
        Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
       
        Session session = cluster.connect("demo");
       
        PreparedStatement ps = session.prepare
                ("insert into emp1(emp_id,ss_id,name) values(?,?,?)");
       
        BoundStatement bs = new BoundStatement(ps);
       
        session.execute(bs.bind(255,320,"javaproficiency"));

        System.out.println("ok");
       
    }
}

No comments:

Post a Comment