Package com.datastax.driver.core

Examples of com.datastax.driver.core.PreparedStatement


        String cql =
            "SELECT schedule_id, time, type, value " +
            "FROM " + MetricsTable.AGGREGATE + " " +
            "WHERE schedule_id = ? AND bucket = ? " +
            "ORDER BY time, type";
        PreparedStatement statement = session.prepare(cql);
        BoundStatement boundStatement = statement.bind(scheduleId, bucket.toString());

        return new SimplePagedResult<AggregateNumericMetric>(boundStatement, new AggregateNumericMetricMapper(),
            storageSession);
    }
View Full Code Here


    final String queryString = QueryStringBuilder.createQueryString(
        _context, lookupContext, _table);
    _log.debug("Created query {}", queryString);
    CassandraVirtualDataWindowLookup result = null;
    synchronized (_session) {
      final PreparedStatement statement = _session.prepare(queryString);
      result = new CassandraVirtualDataWindowLookup(_session,
          lookupContext, statement, _context);
    }
    return result;
  }
View Full Code Here

    final String queryString = QueryStringBuilder.createSelectQueryString(
        _context, lookupContext, _table);
    _log.debug("Created query {}", queryString);
    CassandraVirtualDataWindowLookup result = null;
    synchronized (_session) {
      final PreparedStatement statement = _session.prepare(queryString);
      result = new CassandraVirtualDataWindowLookup(_session,
          lookupContext, statement, _context);
    }
    return result;
  }
View Full Code Here

  public void update(EventBean[] newData, EventBean[] oldData) {
    // Insert events into window
    if (oldData == null) {
      _log.debug("Starting update...");
      final String query = QueryStringBuilder.createInsertQuery(_context);
      PreparedStatement _insertStatement = _session.prepare(query);

      for (EventBean insertBean : newData) {
        final String[] propertyNames = _context.getEventType()
            .getPropertyNames();
        final Object[] values = new Object[propertyNames.length];
        for (int i = 0; i < propertyNames.length; ++i) {
          values[i] = insertBean.get(propertyNames[i]);
        }
        BoundStatement boundStatement = null;
        synchronized (_insertStatement) {
          boundStatement = _insertStatement.bind(values);
        }
        synchronized (_session) {
          _session.execute(boundStatement);
        }
      }
View Full Code Here

      VirtualDataWindowLookupContext lookupContext) {
    final String queryString = createQueryString(_context, lookupContext);
    _log.debug("Created query {}", queryString);
    CassandraVirtualDataWindowLookup result = null;
    synchronized (_session) {
      final PreparedStatement statement = _session.prepare(queryString);
      result = new CassandraVirtualDataWindowLookup(_session,
          lookupContext, statement, _context);
    }
    return result;
  }
View Full Code Here

        List<Column> s = action.getColumns();
        byte[] rowkey = action.getRowKey();

        for (Column c : s) {
            try {
                PreparedStatement statement = session.prepare("INSERT INTO " + keys + "." + table + "(id, colname, colvalue) VALUES (?, ?, ?)");
                BoundStatement boundStatement = new BoundStatement(statement);
                String colName = StandardConverters.convertToString(c.getName());
                checkIfRowExsits(table, rowkey, colName);
                if (c.getValue() != null && c.getValue().length != 0) {
                    session.execute(boundStatement.bind(ByteBuffer.wrap(rowkey), colName, ByteBuffer.wrap(c.getValue())));
View Full Code Here

        byte[] value = column.getPrimaryKey();

        try {
            Object keyObject = null;
            if (key != null) {
                PreparedStatement statement = session.prepare("INSERT INTO " + keys + "." + table + "(id, colname, colvalue) VALUES (?, ?, ?)");
                BoundStatement boundStatement = new BoundStatement(statement);
                if (indexCfName.equalsIgnoreCase("StringIndice")) {
                    keyObject = StandardConverters.convertFromBytes(String.class, key);
                } else if (indexCfName.equalsIgnoreCase("IntegerIndice")) {
                    keyObject = StandardConverters.convertFromBytes(Long.class, key);
                } else if (indexCfName.equalsIgnoreCase("DecimalIndice")) {
                    keyObject = StandardConverters.convertFromBytes(Float.class, key);
                }
                session.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.class, rowKey), keyObject, ByteBuffer.wrap(value)));
            } else {
                PreparedStatement statement = session.prepare("INSERT INTO " + keys + "." + table + "(id, colname, colvalue) VALUES (?, ?, ?)");
                BoundStatement boundStatement = new BoundStatement(statement);
                if (indexCfName.equalsIgnoreCase("IntegerIndice")) {
                    boundStatement.setString("id", StandardConverters.convertFromBytes(String.class, rowKey));
                    boundStatement.setBytesUnsafe("colname", ByteBuffer.wrap(new byte[0]));
                    boundStatement.setBytes("colvalue", ByteBuffer.wrap(value));
View Full Code Here

    final String queryString = QueryStringBuilder.createSelectQueryString(
        _context, lookupContext, _table);
    _log.debug("Created query {}", queryString);
    CassandraVirtualDataWindowLookup result = null;
    synchronized (_session) {
      final PreparedStatement statement = _session.prepare(queryString);
      result = new CassandraVirtualDataWindowLookup(_session,
          lookupContext, statement, _context);
    }
    return result;
  }
View Full Code Here

        String propertiesToUpdate[] = propertiesToUpdateList
            .toArray(new String[propertiesToUpdateList.size()]);
        final String query = QueryStringBuilder.createUpdateQuery(
            _context, propertiesToUpdate);
        PreparedStatement _updateStatement = _session.prepare(query);
        Object primaryKeyValue = null;
        for (EventBean updateBean : newData) {
          final List<Object> values = new ArrayList<Object>();
          for (int i = 0; i < propertiesToUpdate.length; ++i) {
            if (QueryStringBuilder.TABLE_ID
                .equals(propertiesToUpdate[i])) {
              primaryKeyValue = updateBean
                  .get(propertiesToUpdate[i]);
            } else {
              values.add(updateBean.get(propertiesToUpdate[i]));
            }
          }
          values.add(primaryKeyValue);
          BoundStatement boundStatement = null;
          synchronized (_updateStatement) {
            boundStatement = _updateStatement
                .bind(values.toArray());
          }
          synchronized (_session) {
            _session.execute(boundStatement);
          }
View Full Code Here

    {
        String createTableStatement = "CREATE TABLE IF NOT EXISTS " + KEYSPACE + ".qp_cleanup (id int PRIMARY KEY, cid int, val text);";
        String dropTableStatement = "DROP TABLE IF EXISTS " + KEYSPACE + ".qp_cleanup;";

        session.execute(createTableStatement);
        PreparedStatement prepared = session.prepare("INSERT INTO " + KEYSPACE + ".qp_cleanup (id, cid, val) VALUES (?, ?, ?)");
        session.execute(dropTableStatement);
        session.execute(createTableStatement);
        session.execute(prepared.bind(1, 1, "value"));

        session.execute(dropKsStatement);
        session.execute(createKsStatement);
        session.execute(createTableStatement);
        session.execute(prepared.bind(1, 1, "value"));
        session.execute(dropKsStatement);

        // FIXME: where is invalidation actually tested?
  }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.PreparedStatement

Copyright © 2018 www.massapicom. 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.