467,189 Members | 1,378 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

db2 jdbc

hi all,
how do I insert "VARCHAR FOR BIT DATA" via jdbc?
I like to create from an ResaultSet (from a table) Insert-Statements.

How do I hanlde the Field-Types?
Does someone have an example in java?

Thank you very much....

May 10 '06 #1
  • viewed: 1771
Share:
5 Replies
in**@daten-host.de wrote:
hi all,
how do I insert "VARCHAR FOR BIT DATA" via jdbc?
I like to create from an ResaultSet (from a table) Insert-Statements.


You can use the "setBinaryStream" method of the PreparedStatement
class/interface or the "setBytes" method. Alternatively, convert the
binary data to its hex representation and use:

x'...'

in the SQL statement where the ... is the string with the hex
representation.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
May 10 '06 #2
Thank you Knut,
do you have an small example?

May 10 '06 #3
.... and what is the difference between CAHR FOR BIT DATA and VARCAHR
For BIT DATA.
(is there a difference in the insert?)

May 10 '06 #4
in**@daten-host.de wrote:
... and what is the difference between CAHR FOR BIT DATA and VARCAHR
For BIT DATA.
(is there a difference in the insert?)


Well, the same difference as with CHAR and VARCHAR: one has a fixed length
and the other a flexible length. If the stream that you provide to DB2 for
a CHAR FBD column is too short, it will be padded with spaces, i.e. with
trailing x'20' bytes.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
May 10 '06 #5
a new question to that topic:
could I insert the hex-string with PreparedStatements ?

Knut Stolze wrote:
in**@daten-host.de wrote:
... and what is the difference between CAHR FOR BIT DATA and VARCAHR
For BIT DATA.
(is there a difference in the insert?)


Well, the same difference as with CHAR and VARCHAR: one has a fixed length
and the other a flexible length. If the stream that you provide to DB2 for
a CHAR FBD column is too short, it will be padded with spaces, i.e. with
trailing x'20' bytes.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


Jun 2 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Nils Valentin | last post: by
reply views Thread by Raquel | last post: by
3 posts views Thread by Anoop | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.