How to store an object in Riak with the Java client?

Posted by Jonas on Stack Overflow See other posts from Stack Overflow or by Jonas
Published on 2010-04-20T09:18:26Z Indexed on 2010/04/20 9:23 UTC
Read the original article Hit count: 341

I have setup Riak on a Ubuntu machine, and it seam to work if I do riak ping.

Now I would like to use the Riak Java client to store an object, but it doesn't work. I get com.basho.riak.client.response.RiakIORuntimeException when I try to store an object. What am I doing wrong? Is there a way to test if I can access riak from my java client? Do I have to create a Bucket first? how?

import com.basho.riak.client.RiakClient;
import com.basho.riak.client.RiakObject;
import com.basho.riak.client.response.FetchResponse;

public class RiakTest {

    public static void main(String[] args) {

        // connect
        RiakClient riak = new RiakClient("http://192.168.1.107:8098/riak");

        // create object
        RiakObject o = new RiakObject("mybucket", "mykey", "myvalue");

        // store
        riak.store(o);  
    }
}

© Stack Overflow or respective owner

Related posts about riak

Related posts about riak-java-client