Package com.datastax.driver.core

Examples of com.datastax.driver.core.Session.execute()


        final String query = String.format("" + "CREATE keyspace %s "
            + "WITH replication = "
            + "{'class': 'SimpleStrategy', "
            + "'replication_factor' : 3}", keyspace);
        session.execute(query);
        _log.info("Finished creating keyspace {} .", keyspace);
      } catch (Exception e) {
        _log.error("Error creating keyspace {}", keyspace, e);
        error = e;
      }
View Full Code Here


    boolean tableExists = true;
    try {
      _log.info("Started checking whether table {} exists...", table);
      session = _rootCluster.connect(keyspace);
      session.execute(String.format("SELECT * FROM %s LIMIT 10", table));

      _log.info("Finished checking whether table {} exists...", table);
      _log.info("Table {} exists, nothing to do.", table);
    }
    // Keyspace does not exist, so we try to create it.
View Full Code Here

          try {
            _log.info("Started creating table {} ...", table);
            final String createQuery = QueryStringBuilder
                .createCreateTableQuery(context);
            _log.debug("Executing create query: {}", createQuery);
            session.execute(createQuery);
            _log.info("Finished creating table {} .", table);
          } catch (Exception e) {
            _log.error("Error creating table {} .", table);
            error = e;
          }
View Full Code Here

            _log.info("Started granting rights to table {} ...",
                table);
            final String grantQuery = String.format(
                "GRANT ALL on %s TO %s", table, _username);
            _log.debug("Executing grant query: {}", grantQuery);
            session.execute(grantQuery);
            _log.info("Finished granting rights to table {}.",
                table);
          } catch (Exception e) {
            _log.error("Error granting rights to table {}.", table,
                e);
View Full Code Here

        .addContactPoints("127.0.0.1")
        .withPort(9142)
        .build();
    Session session = cluster.connect("cassandra_unit_keyspace");

    ResultSet result = session.execute("select * from testCQLTable1 WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570717");
    String val = result.iterator().next().getString("value");
    assertEquals("1- Cql loaded string", val);

    result = session.execute("select * from testCQLTable2 WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570727");
    val = result.iterator().next().getString("value");
View Full Code Here

    ResultSet result = session.execute("select * from testCQLTable1 WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570717");
    String val = result.iterator().next().getString("value");
    assertEquals("1- Cql loaded string", val);

    result = session.execute("select * from testCQLTable2 WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570727");
    val = result.iterator().next().getString("value");
    assertEquals("2- Cql loaded string", val);
  }

}
View Full Code Here

    Cluster cluster = Cluster.builder()
        .addContactPoints("127.0.0.1")
        .withPort(9142)
        .build();
    Session session = cluster.connect("myownkeyspace");
    ResultSet result = session.execute("select * from testCQLTableKS WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570787");
    String val = result.iterator().next().getString("value");
    assertEquals("KS- Cql loaded string", val);
  }

}
View Full Code Here

    Cluster cluster = Cluster.builder()
        .addContactPoints("127.0.0.1")
        .withPort(9142)
        .build();
    Session session = cluster.connect("cassandra_unit_keyspace");
    ResultSet result = session.execute("select * from testCQLTableRootLocation WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570797");
    String val = result.iterator().next().getString("value");
    assertEquals("Root- Cql loaded string", val);
  }

}
View Full Code Here

    Cluster cluster = Cluster.builder()
        .addContactPoints("127.0.0.1")
        .withPort(9142)
        .build();
    Session session = cluster.connect("cassandra_unit_keyspace");
    ResultSet result = session.execute("select * from testCQLTable WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570737");
    String val = result.iterator().next().getString("value");
    assertEquals("Cql loaded string", val);
  }

}
View Full Code Here

    Cluster cluster = Cluster.builder()
        .addContactPoints("127.0.0.1")
        .withPort(9142)
        .build();
    Session session = cluster.connect("cassandra_unit_keyspace");
    ResultSet result = session.execute("select * from testCQLTable1 WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570717");
    String val = result.iterator().next().getString("value");
    assertEquals("1- Cql loaded string", val);
  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.