Pacific-Design.com

    
Home Index

1. Cassandra

+ CVS Cassandra

+ Clean Data

+ Compaction

+ Compression

+ Couchbase

+ Create Partitions

+ DSE

+ Debugging

+ Examples

+ Firewall

+ Heap Dump

+ Incremental Backup

+ Joining Cluster

+ Kafka

+ Load Data

+ Nodetool

+ OpsCenter

+ Redis

+ Replication

+ Schema

+ Search By Key

+ Search By Value

+ Solr

+ ccm

+ nodetool

+ service

+ sstablekeys

Cassandra /

Cassandra Increase Timeout


$ cqlsh --request-timeout 120 192.168.0.101

Cassandra SQL query with Scala

import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;

object Cassandra {

  val clusterBuilder = Cluster.builder()
  clusterBuilder.addContactPoint("127.0.0.1")
  clusterBuilder.withPort(9042)
  // clusterBuilder.withCredentials("admin", "password") // optional
  val cluster = clusterBuilder.build()
  val session = cluster.connect("kevin")

  def getQueryResult(): Cassandra.type = {

    println(session.getCluster().getClusterName + " connection successful\n")
    System.out.println("system.local: " + session.execute("select now() from system.local").one().getUUID(0));
    val list = session.execute("SELECT * FROM kevin.test").all()
    println(list)

    return this
  }

  def disconnect(str: String) {
    cluster.close()
    session.close()
    println("\n" +
      "" + str + " successfully closed")
  }
}


object App {

  def main(args: Array[String]) {

    try {
      Cassandra.getQueryResult().disconnect("method: getQueryResult")
    } catch {
      case e: Exception => println("exception caught: " + e);
    }

  }
}