470,632 Members | 1,891 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,632 developers. It's quick & easy.

what is the correct DB2 data type to store an encrypted string

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

Nov 30 '06 #1
3 3430
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.

ipy2006 wrote:
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
Nov 30 '06 #2
jefftyzzer wrote:
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.

ipy2006 wrote:
>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).
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
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

WAIUG Conference
http://www.iiug.org/waiug/present/Fo...Forum2006.html
Nov 30 '06 #3
Hi Yasaswi,

ipy2006 wrote:
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).
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

Dec 1 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Brian P. Hammer | last post: by
3 posts views Thread by Todd Gruben | last post: by
2 posts views Thread by Benoit Martin | last post: by
9 posts views Thread by Suresh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.