Sure: package com.footnote.tools.cassandra;
import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Cluster.Builder; import com.datastax.driver.core.Session; public class Test { public static void main(String[] args) { try { Builder builder = Cluster.builder(); Cluster c = builder.addContactPoint("cas121.devf3.com").withPort(9042).build(); Session s = c.connect("rwille"); s.execute("select rhpath from browse_document_tree"); s.shutdown(); } catch (Exception e) { e.printStackTrace(); } System.exit(0); } } Running this program occasionally produces the following output: SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Users/rwille/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-l og4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/Users/rwille/workspace_fold3/dev-backend/extern/slf4j-log4j12-1.6 .1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] - Cannot find LZ4 class, you should make sure the LZ4 library is in the classpath if you intend to use it. LZ4 compression will not be available for the protocol. - [Control connection] Cannot connect to any host, scheduling retry com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried) at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvai lableException.java:64) at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException( ResultSetFuture.java:271) at com.datastax.driver.core.Session$Manager.setKeyspace(Session.java:461) at com.datastax.driver.core.Cluster.connect(Cluster.java:178) at com.footnote.tools.cassandra.Test.main(Test.java:17) Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried) at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:96) at com.datastax.driver.core.Session$Manager.execute(Session.java:513) at com.datastax.driver.core.Session$Manager.executeQuery(Session.java:549) at com.datastax.driver.core.Session$Manager.setKeyspace(Session.java:455) ... 2 more It isn't very often that it fails. I had to run it about 20 times before it got an error. However, because I cannot truncate, I have resorted to dropping and recreating my schema for every unit test. I often have a random test case fail with this same error. The inability to truncate is actually my bigger problem. If I could truncate tables, then I wouldn't have to create so many sessions, and the frequency of this error would be at tolerable levels. Thanks in advance. Robert From: "Turi, Ferenc (GE Power & Water, Non-GE)" <ferenc.t...@ge.com> Reply-To: <user@cassandra.apache.org> Date: Thursday, November 21, 2013 12:26 PM To: "user@cassandra.apache.org" <user@cassandra.apache.org> Subject: RE: Intermittent connection error Hi, Please attach the source to have deeper look at it. Ferenc From: Robert Wille [mailto:rwi...@fold3.com] Sent: Thursday, November 21, 2013 7:11 PM To: user@cassandra.apache.org Subject: Intermittent connection error I intermittently get the following error when I try to execute my first query after connecting: Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried) at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvai lableException.java:64) at com.datastax.driver.core.ResultSetFuture.extractCauseFromExecutionException( ResultSetFuture.java:271) at com.datastax.driver.core.ResultSetFuture.getUninterruptibly(ResultSetFuture. java:187) at com.datastax.driver.core.Session.execute(Session.java:126) at com.datastax.driver.core.Session.execute(Session.java:77) The odd part is the "(no host was tried)". I definitely have provided it with a host, since this exact same code works most of the time. I don't know if this might be related to a question I posted earlier, which I haven't been able to resolve yet. Whenever I issue a truncate command, I get the error "Unable to complete request: one or more nodes were unavailable". I've got a single node with all empty tables. It is definitely up and available, since most of the time I can connect and do stuff (except truncate, which I can never do). The only thing in the logs that looks relevant is this: INFO [HANDSHAKE-/192.168.98.121] 2013-11-20 11:36:59,064 OutboundTcpConnection.java (line 386) Handshaking version with /192.168.98.121 INFO [HANDSHAKE-/192.168.98.121] 2013-11-20 11:37:04,064 OutboundTcpConnection.java (line 395) Cannot handshake version with /192.168.98.121 I'm running Cassandra 2.0.2. Any help would be most appreciated. Thanks Robert