Package com.datastax.driver.core

Examples of com.datastax.driver.core.BoundStatement$DataWrapper


        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));
                    session.execute(boundStatement);
                } else
                    session.execute(boundStatement.bind(StandardConverters.convertFromBytes(String.class, rowKey), "", ByteBuffer.wrap(value)));
          }
        } catch (Exception e) {
            System.out.println(indexCfName + " Exception:" + e.getMessage());
        }
View Full Code Here


    return execute(psc, new PreparedStatementCallback<T>() {
      @Override
      public T doInPreparedStatement(PreparedStatement ps) throws DriverException {
        ResultSet rs = null;
        BoundStatement bs = null;
        if (psb != null) {
          bs = psb.bindValues(ps);
        } else {
          bs = ps.bind();
        }
View Full Code Here

    execute(psc, new PreparedStatementCallback<Object>() {
      @Override
      public Object doInPreparedStatement(PreparedStatement ps) throws DriverException {
        ResultSet rs = null;
        BoundStatement bs = null;
        if (psb != null) {
          bs = psb.bindValues(ps);
        } else {
          bs = ps.bind();
        }
View Full Code Here

    return execute(psc, new PreparedStatementCallback<List<T>>() {
      @Override
      public List<T> doInPreparedStatement(PreparedStatement ps) throws DriverException {
        ResultSet rs = null;
        BoundStatement bs = null;
        if (psb != null) {
          bs = psb.bindValues(ps);
        } else {
          bs = ps.bind();
        }
View Full Code Here

      public Object doInSession(Session s) throws DataAccessException {

        String cql = "insert into book (isbn, title, author, pages) values (?, ?, ?, ?)";

        PreparedStatement ps = s.prepare(cql);
        BoundStatement bs = ps.bind(isbn, title, author, pages);

        s.execute(bs);

        return null;
View Full Code Here

  @Test
  public void executeTestCqlStringPreparedStatementCallback() {

    String cql = "insert into book (isbn, title, author, pages) values (?, ?, ?, ?)";

    BoundStatement statement = cqlTemplate.execute(cql, new PreparedStatementCallback<BoundStatement>() {

      @Override
      public BoundStatement doInPreparedStatement(PreparedStatement ps) throws DriverException, DataAccessException {
        BoundStatement bs = ps.bind();
        return bs;
      }
    });

    assertNotNull(statement);
View Full Code Here

  @Test
  public void executeTestPreparedStatementCreatorPreparedStatementCallback() {

    final String cql = "insert into book (isbn, title, author, pages) values (?, ?, ?, ?)";

    BoundStatement statement = cqlTemplate.execute(new PreparedStatementCreator() {

      @Override
      public PreparedStatement createPreparedStatement(Session session) throws DriverException {
        return session.prepare(cql);
      }
    }, new PreparedStatementCallback<BoundStatement>() {

      @Override
      public BoundStatement doInPreparedStatement(PreparedStatement ps) throws DriverException, DataAccessException {
        BoundStatement bs = ps.bind();
        return bs;
      }
    });

    assertNotNull(statement);
View Full Code Here

      // final ColumnDefinitions columns = _statement.getVariables();
      // for(int i=0; i<columns.size(); ++i) {
      // Object key = keys[i];
      // columns.getType(i).
      // }
      final BoundStatement boundStatement = _statement.bind(keys);

      final ResultSet cassandraResultList = _session
          .execute(boundStatement);

      final CassandraRowVisitor rowVisitor = new CassandraRowVisitor(
View Full Code Here

      final Object[] values = new Object[propertyNames.length];
      for (EventBean insertBean : newData) {
        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);
        }
      }

      _log.debug("Finished insert...");
    }
    // Delete events from window
    else if (newData == null) {

    }
    // Update events in window
    else {
      if (newData.length > 0) {
        _log.debug("Starting update...");
        EventBean newDataFirst = newData[0];
        List<String> propertiesToUpdateList = new ArrayList<String>();
        for (String propertyName : propertyNames) {
          if (newDataFirst.get(propertyName) != null) {
            propertiesToUpdateList.add(propertyName);
          }
        }

        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) {
View Full Code Here

   * <strong>Note: This method is thread-safe.</strong>
   * </p>
   */
  @Override
  public Set<EventBean> lookup(Object[] keys, EventBean[] eventsPerStream) {
    final BoundStatement boundStatement = _statement.bind(keys);

    final ResultSet cassandraResultList = _session.execute(boundStatement);

    final Set<EventBean> esperResultSet = new HashSet<EventBean>();
    final Iterator<Row> it = cassandraResultList.iterator();
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.BoundStatement$DataWrapper

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.