By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.