Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / November 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ipy2006 - 30 Nov 2006 19:31 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.