Hello,

I would try something like that (I have not tested, no guarantee ..) :

import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.utils.Bytes;

/* ... */

        ResultSet result = null; // Put your instance HERE
        final StringBuilder builder = new StringBuilder();
        for (Row row : result) {
            builder.append("[ ");
            for (ColumnDefinitions.Definition def :
row.getColumnDefinitions()) {
                String value =
Bytes.toHexString(row.getBytesUnsafe(def.getName()));

builder.append(def.getName()).append("=").append(value).append(" ");
            }
            builder.append("] ");
        }
        System.out.println(builder.toString());

/* ... */

But this is probably not very usefull, since you get only prints of bytes.
You can then test the type of the column (variable 'def') in order to call
the best suited method of 'row', so that the variable 'value' can be more
readable.


Fabrice LARCHER


2014-08-19 3:29 GMT+02:00 Kevin Burton <bur...@spinn3r.com>:

> The DataStax java driver has a Row object which getInt, getLong methods…
>
> However, the getString only works on string columns.
>
> That's probably reasonable… but if I have a raw Row, how the heck do I
> easily print it?
>
> I need a handy way do dump a ResultSet …
>
> --
>
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
> <http://spinn3r.com>
>
>

Reply via email to