TTserver java客户端访问

 

package tokyotyrant.example;

import tokyotyrant.MRDB;
import tokyotyrant.networking.NodeAddress;
import tokyotyrant.transcoder.DoubleTranscoder;
import tokyotyrant.transcoder.IntegerTranscoder;

public class MRDBExample {
        public static void main(String[] args) throws Exception {
                Object value;

                // create the object
                MRDB db = new MRDB();

                // connect to the servers
                db.open(NodeAddress.addresses("tcp://localhost:1978"));

                // store records
                if (!db.await(db.put("foo", "hop"))
                                || !db.await(db.put("bar", "step"))
                                || !db.await(db.put("baz", "jump"))) {
                        System.err.println("put error");
                }

                // retrieve records
                value = db.await(db.get("foo"));
                if (value != null) {
                        System.out.println(value);
                } else {
                        System.err.println("get error");
                }

                // add int
                db.put("int", 3, new IntegerTranscoder());
                int i = db.await(db.addint("int", 4));
                System.out.println(i);

                // add double
                db.put("d", 3.0D, new DoubleTranscoder());
                double d = db.await(db.adddouble("d", 4.0D));
                System.out.println(d);

                // close the connections
                db.close();
        }
}

 

需要netty-3.2.2.jar,slf4j-api-1.6.1.jar,slf4j-nop-1.6.1.jar等几个jar包

 

window下需要sum1.6jdk ,jrockit会报

ava.lang.UnsatisfiedLinkError: no nio in java.library.path

异常,找不到jni的一个dll

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值