File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes how to handle data gotten from CLOBs? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to handle data gotten from CLOBs?" Watch "how to handle data gotten from CLOBs?" New topic
Author

how to handle data gotten from CLOBs?

Philip Fry
Greenhorn

Joined: Sep 21, 2011
Posts: 6
Hello,

I need some guidance with handling clob data. I have a derby table:

Hashes and salts are generated like this:

Then records are stored like this:

This bit works fine. At least I am convinced so.
Once I store the digests in a DB I use this method to compare them:

Hash and salt arguments being passed to the compareHashes() are the ones retrieved from a database with:

and also:

Clearly I am doing something wrong with getting data from Clobs. And this:

is the only way I coud come up with to convert the clob back to array, which isn't working like i would like it to. I thought byte[] arrays passed were binary and since clobs are? also binary it would work with out additional conversions.
Do any of you have any ideas/suggestions/libraries which would be able to convert the clobs to what I want?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Philip Fry wrote:since clobs are? also binary


CLOB: Character Large Object

BLOB: Binary Large Object
Philip Fry
Greenhorn

Joined: Sep 21, 2011
Posts: 6
I was under the impression that blobs were for files like media files or pictures? Also I am not able to insert to Blob type fields things like: 81-88108101-39-95348102-413-2318-44-95-4029-92-11-53115-124-89-89080-102126888411531
because an exception is being thrown:



And it works with clobs type fields.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Philip Fry wrote:I was under the impression that blobs were for files like media files or pictures? Also I am not able to insert to Blob type fields things like: 81-88108101-39-95348102-413-2318-44-95-4029-92-11-53115-124-89-89080-102126888411531
because an exception is being thrown:


Blobs are -- just as their name says -- Binary Large Objects. It's true that the files you mention are binary and can be large, but it doesn't follow from that statement that you can't use Blobs for anything else.

And no, you can't put character data into them. You have to put bytes into them. Naturally you can't do that if you're constructing your SQL statements in a String (I can't believe you're doing all of this login security and then using a technology which is susceptible to SQL injection attacks). You can put bytes into them if you use a PreparedStatement and then use its setBlob() or setBinaryStream() method.
Philip Fry
Greenhorn

Joined: Sep 21, 2011
Posts: 6
Thank you very much good sir.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to handle data gotten from CLOBs?