我有以下java代码来连接cassandra。它给出了 java.lang.NumberFormatException
任何想法?
package com.retail;
import org.apache.cassandra.thrift.*;
import org.apache.thrift.protocol.*;
import org.apache.thrift.transport.*;
import java.lang.*;
public class ShowKeyspaces {
public static void main(String args[]) throws Exception {
String host = System.getenv("localhost");
int port = Integer.parseInt(System.getenv("9160"));
TSocket socket = new TSocket(host,port);
TTransport transport = new TFramedTransport(socket);
TProtocol proto = new TBinaryProtocol(transport);
transport.open();
Cassandra.Client client = new Cassandra.Client(proto);
System.out.println("Version: "+client.describe_version());
System.out.println("cluster name : "+client.describe_cluster_name());
transport.close();
}
}
它给出的错误是:
**Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at com.retail.ShowKeyspaces.main(ShowKeyspaces.java:14)**
知道我应该怎么做吗???
谢谢!