private PreparedStatement prepareQuery(String tableName, Query query) {
        // All queries start with SELECT * FROM <keyspace>.<table>
        StringBuilder cql = new StringBuilder("SELECT * FROM ");
        cql.append(m_keyspace);
        cql.append(".");
        cql.append(tableName);
        
        switch (query) {
        case SELECT_1_ROW_1_COLUMN:
            cql.append(" WHERE key = ? AND column1 = ?;");
            break;
        case SELECT_1_ROW_COLUMN_RANGE:
            cql.append(" WHERE key = ? AND column1 >= ? AND column1 < ? LIMIT ?;");
            break;
        case SELECT_1_ROW_COLUMN_SET:
            cql.append(" WHERE key = ? AND column1 IN ?;");
            break;
        case SELECT_1_ROW_ALL_COLUMNS:
            cql.append(" WHERE key = ? LIMIT ?;");
            break;
        case SELECT_1_ROW_UPPER_COLUMNS:
            cql.append(" WHERE key = ? AND column1 >= ? LIMIT ?;");
            break;
        case SELECT_1_ROW_LOWER_COLUMNS:
            cql.append(" WHERE key = ? AND column1 <= ? LIMIT ?;");
            break;
        case SELECT_ROWS_RANGE:
            //unfortunately I didn't find how to get first column of each row in CQL.
            cql.append(" ;");
            break;
        default: 
            throw new RuntimeException("Not supported: " + query);
        }
        m_logger.debug("Preparing query {}: {}", query, cql);
        return ((CQLService)DBService.instance(m_tenant)).getSession().prepare(cql.toString());
    }
private PreparedStatement prepareQuery ( String tableName , Query query ) { StringBuilder cql = new StringBuilder ( "SELECT * FROM " ) ; cql . append ( m_keyspace ) ; cql . append ( "." ) ; cql . append ( tableName ) ; switch ( query ) { case SELECT_1_ROW_1_COLUMN : cql . append ( " WHERE key = ? AND column1 = ?;" ) ; break ; case SELECT_1_ROW_COLUMN_RANGE : cql . append ( " WHERE key = ? AND column1 >= ? AND column1 < ? LIMIT ?;" ) ; break ; case SELECT_1_ROW_COLUMN_SET : cql . append ( " WHERE key = ? AND column1 IN ?;" ) ; break ; case SELECT_1_ROW_ALL_COLUMNS : cql . append ( " WHERE key = ? LIMIT ?;" ) ; break ; case SELECT_1_ROW_UPPER_COLUMNS : cql . append ( " WHERE key = ? AND column1 >= ? LIMIT ?;" ) ; break ; case SELECT_1_ROW_LOWER_COLUMNS : cql . append ( " WHERE key = ? AND column1 <= ? LIMIT ?;" ) ; break ; case SELECT_ROWS_RANGE : cql . append ( " ;" ) ; break ; default : throw new RuntimeException ( "Not supported: " + query ) ; } m_logger . debug ( "Preparing query {}: {}" , query , cql ) ; return ( ( CQLService ) DBService . instance ( m_tenant ) ) . getSession ( ) . prepare ( cql . toString ( ) ) ; }
Create a prepared statement for the given query/table combo.