• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting LONGVARBINARY of HSQL to BLOB of Derby

 
Tauri Valor
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to convert LONGVARBINARY field of a table in HSQL database to BLOB in Derby as LONGVARBINARY is not a valid datatype in Derby.

When I convert it to BLOB while migrating the data from HSQL to DERBY, Im getting an error like this:

An attempt was made to put a data value of type 'java.lang.String' into a data value of type 'BLOB'.


So Im trying to change String value into a byte array using String.getBytes() function.


And I used the following code to change from String to byte array..





Now what I want to know is how to insert the this byte array in the table.. ?

Please give me a clue..
 
Scott Selikoff
author
Bartender
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use toString() method but that won't actually work well because of character encoding rules. You may need to manually convert the byte array to a string format that HSQL understands then just use a setString on a prepared statement to set the data.

Although not all jdbc drivers support this method of creating records with blobs/clobs. Others require multiple passes to do an insert. The first to insert a record without the clob/blob, the second to read the record and obtain a pointer to the clob/blob, and a third to actually set the clob/blob data. This is why you cannot create a clob/blob java object yourself, you can only use one the system gives you access to.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!