Subject | RE: [Firebird-Java] Re: MD5 in VARCHAR |
---|---|
Author | Robert DiFalco |
Post date | 2003-07-02T21:25:25Z |
Oddly enough. It seems to require 28 OCTETS characters to hold 16 bytes.
Not sure how that match works out.
-----Original Message-----
From: Robert DiFalco
Sent: Wednesday, July 02, 2003 2:10 PM
To: Firebird-Java@yahoogroups.com
Subject: RE: [Firebird-Java] Re: MD5 in VARCHAR
OCTETS works but I think there is a problem with calculating the field
length. If the field is 16 characters (the length of an MD5) I get a
data truncation exception while 32 works. Maybe it splits each byte into
a character of 128 bits instead of 256? Try something like this:
CREATE TABLE Test
(
f_md5 VARCHAR(16) CHARACTER SET OCTETS
);
PreparedStatement ps = con.prepareStatement( "INSERT INTO Test(f_md5)
VALUES (?);" );
String s = "test string";
MessageDigest md = MessageDigest.getInstance( "MD5" );
byte data[] = md.digest( s );
s.setBytes( 1, data );
ps.execute();
-----Original Message-----
From: Roman Rokytskyy [mailto:rrokytskyy@...]
Sent: Wednesday, July 02, 2003 11:45 AM
To: Firebird-Java@yahoogroups.com
Subject: [Firebird-Java] Re: MD5 in VARCHAR
different than NONE, you will get transliteration errors.
Can you provide a test case, so I can quickly check why driver
complains on data truncation in first example?
Thanks!
Roman
Yahoo! Groups Sponsor
ADVERTISEMENT
To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Yahoo! Groups Sponsor
ADVERTISEMENT
To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Not sure how that match works out.
-----Original Message-----
From: Robert DiFalco
Sent: Wednesday, July 02, 2003 2:10 PM
To: Firebird-Java@yahoogroups.com
Subject: RE: [Firebird-Java] Re: MD5 in VARCHAR
OCTETS works but I think there is a problem with calculating the field
length. If the field is 16 characters (the length of an MD5) I get a
data truncation exception while 32 works. Maybe it splits each byte into
a character of 128 bits instead of 256? Try something like this:
CREATE TABLE Test
(
f_md5 VARCHAR(16) CHARACTER SET OCTETS
);
PreparedStatement ps = con.prepareStatement( "INSERT INTO Test(f_md5)
VALUES (?);" );
String s = "test string";
MessageDigest md = MessageDigest.getInstance( "MD5" );
byte data[] = md.digest( s );
s.setBytes( 1, data );
ps.execute();
-----Original Message-----
From: Roman Rokytskyy [mailto:rrokytskyy@...]
Sent: Wednesday, July 02, 2003 11:45 AM
To: Firebird-Java@yahoogroups.com
Subject: [Firebird-Java] Re: MD5 in VARCHAR
> Is there a character set I can use to store an MD5 into a VARCHAR? IWhat is the character set you specify for connection? If it is
> tried CHARACTER SET NONE and NCHAR but these do not seem to work.
> I'd rather not BASE64Encode it if at all possible. Not sure if this
> is a driver issue or a data definition problem on my part. Here's
> the exceptions I get when I try to write the value:
different than NONE, you will get transliteration errors.
Can you provide a test case, so I can quickly check why driver
complains on data truncation in first example?
Thanks!
Roman
Yahoo! Groups Sponsor
ADVERTISEMENT
To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Yahoo! Groups Sponsor
ADVERTISEMENT
To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.