Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ms SQL Decimal Field Conversion into binary in JDBC

 
Zubair Safenet
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a JDBC application. My Task is to get the data from SQL server encrypt them and then store them in another table as varbinary field. I have successfully converted all sql data types to binary except decimal field.

I am using getBytes() method of JDBC to get the bytes for this decimal field. But the bytes I am receiving are not valid bytes for example I am running one query in sql which will convert decimal to binary as

declare @deci decimal(18,2)
set @deci = 2.33
print cast(@deci as varbinary)

as a result I get -- 0x12020001E9000000 (for my application to work properly I need this binary on JDBC side) : (5 bytes)

but on the JDBC side I get bytes as (for the same value) -- 2,1,-23,3,0 (5 bytes)(I am printing the value of each byte)

can anybody help me to understand the difference?? and how to convert these JDBC bytes to above varbinary

Thanks in advance

[Rob: Removed size tags]
 
Wei Dai
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try to convert Decimal into varchar first, then encrypt it.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch Zubair, I hope you find us helpful (unfortunatly I am not going to be )
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic