• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to read and write binary Bytes in MySQL ?

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am working on a Java-MySQL project to compute the hash value of a document using Java MessageDigest. The output is 16 bytes of type Java 'byte'. I store the value in MySQL CHAR types(using Jdbc). When I read back the stored value from MySQL using resultSet.getBytes(); the read hash value is not the same as the stored value. Some characters are differenet. I think the problem must be from a mismatch between MySQL and Java data types or a character coding format.

Can any body please help me how to solve this problem. What data types I should use in MySQL and Java? what character coding should I use?

Thanks for your help.

Jim.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim,
MySql 4 and above have a "binary" type. It will store your bytes without conversion.
[ March 02, 2005: Message edited by: Jeanne Boyarsky ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic