Попытка соединить Cassandra с Java с помощью приведенного ниже кода и получить localhost / 127.0.0.1: 9042] Невозможно соединиться с ошибкой -
public static void main(String[] args)
{
Cluster cluster;
Session session;
//cluster connects to the address of the node provided.One contact point is required.Good to have multiple
cluster=Cluster.builder().addContactPoint("localhost").build();
session=cluster.connect("ecommerce");
session.execute("INSERT INTO products (pdt_id, cat_id, pdt_name, pdt_desc, price, shipping) VALUES (002,105, 'Candy 0.9 cu. ft. Washing Machine', 'Capacity of 1 cu. ft.10 different power levels', 64.00, 'Expedited')");
session.execute("INSERT INTO products (pdt_id, cat_id, pdt_name, pdt_desc, price, shipping) VALUES (003,106, 'Prestige 0.9 cu.cm. Pressure Cooker', 'Capacity: 18 qt.', 70.00, 'Dispatched from warehouse')");
String pdtid = null, pdtname = null, pdtdesc = null;
float price = 0;
ResultSet resultSet=session.execute("select * from products");
for(Row row:resultSet)
{
pdtid = Integer.toString(row.getInt("pdt_id"));
pdtname = row.getString("pdt_name");
}
cluster.close();
}
}