Examples of BoundStatement


Examples of com.datastax.driver.core.BoundStatement

        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
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.