我在 eclipse 中有一个代码,我已经成功建立了 cassandra 连接。连接成功完成,但我看到 eclipse 中的红色大按钮仍然亮着,即过程尚未完成。我想像执行普通代码一样关闭红色按钮。这是我的代码...
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;
public class MyConnection{
private Cluster cluster;
public void connect(String node) {
cluster = Cluster.builder().addContactPoint(node).build();
Metadata metadata = cluster.getMetadata();
System.out.println("Cassandra connection established");
System.out.printf("Connected to cluster: %s\n",
metadata.getClusterName());
for (Host host : metadata.getAllHosts()) {
System.out.printf("Datatacenter: %s; Host: %s; Rack: %s \n",
host.getDatacenter(), host.getAddress(), host.getRack());
}
}
public void close() {
cluster.shutdown();
}
public static void main(String[] args) {
MyConnection c = new MyConnection();
c.connect("127.0.0.1");
c.close();
}
}
这是代码。有人请帮助..