0

How to get the "varbinary" content as it is from MySql, as java string while making a stored procedure call?

So, I am making a simple JDBC call with my StoredProcedure name and input parameters map(parametersMap):- Map map = call.execute(parametersMap);

and I am getting a "varbinary" field as Object which has "B@6550f5eb" as value.. But I need it in String format as it is(say 0x64756D6D792064617461).

I tried doing getBytes() but it's not able to cast.

This is my table :-

CREATE TABLE table1 (
    id int,
    key varchar(255),
    keyType varchar(20),
    content varbinary(max)
)

This is my StoredProcedure:-

ALTER PROCEDURE docContent
    @DocId AS INT
AS
BEGIN
    SET NOCOUNT ON;

    SELECT content
    FROM table1
    WHERE id  = @DocId
END
ace
  • 139
  • 2
  • 6
  • If the string representation of your object actually begins with `[B@`, then it's a byte array. – khelwood Sep 23 '19 at 09:27
  • See [How to convert a byte array to a hex string in Java?](https://stackoverflow.com/questions/9655181/how-to-convert-a-byte-array-to-a-hex-string-in-java) – khelwood Sep 23 '19 at 09:29

0 Answers0