需要导入jar:
cassandra-driver-core-3.0.0-beta1-bb1bce4-SNAPSHOT-shaded.jar
guava-18.0.jar
log4j-1.2.17.jar
metrics-core-3.1.0.jar
slf4j-api-1.7.7.jar
slf4j-log4j12-1.7.5.jar
代码:
Cluster cluster = Cluster.builder().addContactPoint("192.168.1.103").build(); Session session = cluster.connect(); String cql = "select * from demodb.afttre;"; ResultSet resultSet = session.execute(cql); Iterator<Row> iterator = resultSet.iterator(); while (iterator.hasNext()) { Row row = iterator.next(); System.out.println(row.getObject("month")); } session.close(); cluster.close();
时间: 2024-10-13 12:12:18