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

db2 jdbc

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


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

P: n/a
Thank you Knut,
do you have an small example?

May 10 '06 #3

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

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

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