clojure.java.jdbc byte[] result type question

48 views
Skip to first unread message

rossputin

unread,
Jun 1, 2012, 8:26:28 AM6/1/12
to Clojure
Hi.

I've got a clojure.java.jdbc result coming back as a byte[]. Its from
a GROUP_CONCAT on an int(10) field.

In the mysql client the result is: '1,2,4,6,7,19,24,32,54,152'.

I am unsure how to extract this result properly in clojure… (println
(seq (somevar))) gives me an unexpected result: (49 44 50 44 52 44 54
44 55 44 49 57 44 50 52 44 51 50 44 53 52 44 49 53 50).

Any ideas what I should be doing ?

Thanks!

Sean Corfield

unread,
Jun 2, 2012, 5:20:00 PM6/2/12
to clo...@googlegroups.com
On Fri, Jun 1, 2012 at 5:26 AM, rossputin <ross...@gmail.com> wrote:
> I've got a clojure.java.jdbc result coming back as a byte[].  Its from
> a GROUP_CONCAT on an int(10) field.
>
> In the mysql client the result is: '1,2,4,6,7,19,24,32,54,152'.

Looks like a string? (coming back as a byte array)

> I am unsure how to extract this result properly in clojure… (println
> (seq (somevar))) gives me an unexpected result: (49 44 50 44 52 44 54
> 44 55 44 49 57 44 50 52 44 51 50 44 53 52 44 49 53 50).

I guess you'd need to convert the byte array to a String and then
split it at "," and then parse each item to an int. Perhaps something
like:

(map #(Integer/parseInt %) (.split (String. somevar) ","))
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

rossputin

unread,
Jun 3, 2012, 6:51:47 AM6/3/12
to Clojure
Hey. Yes, thanks for your help, it was a String as a byte array.

On Jun 2, 10:20 pm, Sean Corfield <seancorfi...@gmail.com> wrote:
> On Fri, Jun 1, 2012 at 5:26 AM, rossputin <rossaj...@gmail.com> wrote:
> > I've got a clojure.java.jdbc result coming back as a byte[].  Its from
> > a GROUP_CONCAT on an int(10) field.
>
> > In the mysql client the result is: '1,2,4,6,7,19,24,32,54,152'.
>
> Looks like a string? (coming back as a byte array)
>
> > I am unsure how to extract this result properly in clojure… (println
> > (seq (somevar))) gives me an unexpected result: (49 44 50 44 52 44 54
> > 44 55 44 49 57 44 50 52 44 51 50 44 53 52 44 49 53 50).
>
> I guess you'd need to convert the byte array to a String and then
> split it at "," and then parse each item to an int. Perhaps something
> like:
>
> (map #(Integer/parseInt %) (.split (String. somevar) ","))
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View --http://corfield.org/
> World Singles, LLC. --http://worldsingles.com/
Reply all
Reply to author
Forward
0 new messages