I encrypted a string within a Java application. I need to store that
encrypted string in a given field in the DB2 database. Currently the
datatype for that field is char(10). I am getting a SQLCODE: -302
error, which means incompatible data types.
The encrypted strings are longer than 10 characters. I am not sure if
BLOB data type needs to be used or if I can increase my existing field
to char(30).
Thanks,
Yasaswi
jefftyzzer - 30 Nov 2006 20:25 GMT
The error you're getting is that the destination field is too small for
what you want to store, not that the datatype is incompatible. Just
increase the length from 10.
> I encrypted a string within a Java application. I need to store that
> encrypted string in a given field in the DB2 database. Currently the
[quoted text clipped - 7 lines]
> Thanks,
> Yasaswi
Serge Rielau - 30 Nov 2006 23:47 GMT
> The error you're getting is that the destination field is too small for
> what you want to store, not that the datatype is incompatible. Just
[quoted text clipped - 8 lines]
>> BLOB data type needs to be used or if I can increase my existing field
>> to char(30).
You probably should switch to VARCHAR though. There is no telling how
your decryption will react when you get blank padding.
Also I recommend you use FOR BIT DATA:
E.g. VARCHAR(100) FOR BIT DATA
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
WAIUG Conference
http://www.iiug.org/waiug/present/Forum2006/Forum2006.html
Joachim Banzhaf - 30 Nov 2006 22:12 GMT
Hi Yasaswi,
> I encrypted a string within a Java application. I need to store that
> encrypted string in a given field in the DB2 database. Currently the
[quoted text clipped - 4 lines]
> BLOB data type needs to be used or if I can increase my existing field
> to char(30).
You can increase the fieldsize, no problem here.
But what's much more important, is, that you should change the field to char
for bit data!
If you don't, and your DB uses (or will use later) a different codepage than
some client, DB2 will perform automatic codepage conversion of the string,
which will make the string undecryptable for the client.
HTH,
Joachim Banzhaf