Package com.datastax.driver.core

Examples of com.datastax.driver.core.PreparedStatement


        return statementForInt(session, key, cql);
    }

    private PreparedStatement statementForInt(Session session, StatementKey key, String cql) {
        PreparedStatement ps = globalPstmtCache.get(cql);
        if (ps != null) {
            return ps;
        }

        SettableFuture<PreparedStatement> future = SettableFuture.create();
View Full Code Here


            this.future = future;
        }

        PreparedStatement get() {
            Future<PreparedStatement> f = future;
            PreparedStatement ps = pstmt;
            if (ps != null) {
                return ps;
            }
            try {
                return Uninterruptibles.getUninterruptibly(f);
View Full Code Here

                                      Binder binder) {
        if (isAbstract) {
            throw new ModelUseException("type " + type.getName() + " is abstract");
        }

        PreparedStatement pStmt = preparedStatements.statementFor(session, statementType, binder, persistOptions);
        BoundStatement bStmt = pStmt.bind();

        binder.bindColumns(0, bStmt);

        PersistOption.forBoundStatement(persistOptions, bStmt);
        return bStmt;
View Full Code Here

            }
        } catch (Throwable t) {
            throw new RuntimeException("Invalid primary key element "+Arrays.toString(primaryKey), t);
        }

        PreparedStatement pstmt = preparedStatements.statementFor(session, PreparedStatements.StatementType.SELECT, binder, persistOptions);
        BoundStatement bStmt = pstmt.bind();
        statementOptions.applyRead(bStmt, readConsistencyLevel, persistOptions);
        PersistOption.forBoundStatement(persistOptions, bStmt);

        idx = binder.bindColumns(0, bStmt);
View Full Code Here

        buildModifyBindColumns(container, binder);

        Session session = persistenceSession.driverSession();

        PreparedStatement pstmt = preparedStatements
            .statementFor(session, PreparedStatements.StatementType.SELECT, binder, persistOptions);
        BoundStatement bStmt = pstmt.bind();
        statementOptions.applyRead(bStmt, readConsistencyLevel, persistOptions);
        PersistOption.forBoundStatement(persistOptions, bStmt);

        int idx = binder.bindColumns(0, bStmt);
View Full Code Here

            return;
        }

        CqlColumn[] readColumns = readColumns(persistOptions);

        PreparedStatement pstmt = preparedStatements.statementFor(queryBinder.session, PreparedStatements.StatementType.SELECT,
            readColumns, queryBinder.conditionFor((Class<? extends T>) type), persistOptions);
        BoundStatement bStmt = pstmt.bind();
        statementOptions.applyRead(bStmt, readConsistencyLevel, persistOptions);
        PersistOption.forBoundStatement(persistOptions, bStmt);
        queryBinder.addStatement((Class<? extends T>) type, bStmt, readColumns);
    }
View Full Code Here

        byte[] nullArray  = StandardConverters.convertToBytes(SpiConstants.NULL_STRING_FORCQL3);

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

        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

    if (sessionMap == null) {
      sessionMap = new ConcurrentHashMap<String, PreparedStatement>();
      psMap.put(session, sessionMap);
    }

    PreparedStatement pstmt = sessionMap.get(keyspaceCQLKey.toString());
    if (pstmt == null) {
      log.debug("No Cached PreparedStatement found...Creating and Caching");
      pstmt = session.prepare(this.cql);
      sessionMap.put(keyspaceCQLKey.toString(), pstmt);
    } else {
View Full Code Here

  @Override
  public <T> T execute(PreparedStatementCreator psc, PreparedStatementCallback<T> action) {

    try {
      PreparedStatement ps = psc.createPreparedStatement(getSession());
      return action.doInPreparedStatement(ps);
    } catch (DriverException dx) {
      throw translateExceptionIfPossible(dx);
    }
  }
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.