0

background

I have an android client which sends image as string base64 to a jersey web service, then I want to save this image into my sql servier 2008 r2 database. I want to convert that string to varbinary.

my question

how to convert string to varbinary

Thank you

1 Answer 1

1

JDBC maps varbinary to byte arrays. So this means that you first have to convert your base64 String to a byte array. This is what any Base64 implementation does. You just have to pick one.

With Apache Commons, for example, you would something like:

String myEncodedImage = "...";
byte[] myImage = Base64.decodeBase64(myEncodedImage);

And then you would simply pass that byte array to your persistency layer, JDBC will take care of the rest.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.